Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
till1993 opened this issue Mar 10, 2023 · 3 comments · Fixed by #536
Closed

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

till1993 opened this issue Mar 10, 2023 · 3 comments · Fixed by #536
Assignees

Comments

@till1993
Copy link

till1993 commented Mar 10, 2023

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.

@Vinzius
Copy link
Contributor

Vinzius commented Mar 11, 2023

Hi @till1993,

Thanks for taking time to open this issue, and adding a suggestion :-)

We'll take a look next week!

Have a nice week-end,
Vincent

@Vinzius Vinzius self-assigned this Mar 21, 2023
@Vinzius
Copy link
Contributor

Vinzius commented Mar 21, 2023

Hello 😄

I modified a bit your code to have unknown as input and pass our pipelines (#536). Feel free to suggest a different approach.

Question for you: do you want to test this branch (e.g. with yalc) before we merge, or is it okay to proceed?

Have a nice week,
Vincent

@Vinzius
Copy link
Contributor

Vinzius commented Mar 27, 2023

@till1993 I guess it's okay to proceed. We'll merge; it should be included it in the next version (early this week).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants