Skip to content

Scaleway sdk with remix run leads to TypeError: Invalid response object #509

@till1993

Description

@till1993

Hi everyone,

I encountered a bug with the Scaleway SDK for JavaScript. We are using your SDK in our Remix.run application to create or fetch tokens for accessing serverless containers.

Starting with version 0.1.0-beta35, all requests to Scaleway APIs are failing with the error "TypeError: Invalid response object."

The issue can be traced back to the following check in the index.cjs file:

const responseParser = (unmarshaller, responseType) => async response => {
  if (!(response instanceof Response)) {
    throw new TypeError('Invalid response object');
  }
  ....
}

However, the Response object is not unique within the Remix/React-Router context. They have encountered similar issues that can be found here:
related issue: remix-run/remix#4741
PRs to fix it:
remix-run/react-router#9690
remix-run/remix#4782

I suggest replacing the instanceof Response check with something like:

export function isResponse(value: any): value is Response {
  return (
    value != null &&
    typeof value.status === "number" &&
    typeof value.statusText === "string" &&
    typeof value.headers === "object" &&
    typeof value.body !== "undefined"
  );
}

We are currently stuck on version 0.1.0-beta34 until this issue is resolved. Please let me know if you have any further questions.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions