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

lib/user-methods.js's performFetch API is unstable across platforms #2274

Closed
kraenhansen opened this issue Mar 7, 2019 · 6 comments
Closed
Labels

Comments

@kraenhansen
Copy link
Member

kraenhansen commented Mar 7, 2019

Goals

We have to make a choice: Either the performFetch method of lib/user-methods.js should adhere to the fetch API, which means that we should be able to read header values from a response such as response.headers.get('Content-Type') or we should simplify the way we call the method making less assumptions on the shape of the response object (I don't recommend the latter).

In its current implementation performFetch performs very differently whether Realm JS is running on Node.js or in an environment with fetch available.

We currently have tests failing on master due to this discrepancy in behaviour across platforms.

Version of Realm and Tooling

  • Realm JS SDK Version: 2.24.0
  • Node or React Native: Both - but mostly React Native and Electron exhibits regressions.
  • Client OS & Version: N/A
  • Which debugger for React Native: N/A
@tgoyne
Copy link
Member

tgoyne commented Mar 7, 2019

That test failed because the network request to github failed, not because it couldn't read the content type header. The bit about not getting the correct content type is the expected result.

@kraenhansen
Copy link
Member Author

Okay - I might have been a little too quick in my conclusion.

@bradjonesca
Copy link

FYI: whatwg/fetch#878

@kraenhansen
Copy link
Member Author

I am sorry to report that we still have an issue with this implementation on Electron when called from the main process:

ReferenceError: XMLHttpRequest is not defined
     at fetchWithTimeout (/Users/kraenhansen/Repositories/realm-studio/node_modules/realm/lib/user-methods.js:82:17)
     at next (/Users/kraenhansen/Repositories/realm-studio/node_modules/realm/lib/user-methods.js:125:9)
     at Promise (/Users/kraenhansen/Repositories/realm-studio/node_modules/realm/lib/user-methods.js:140:13)
     at new Promise (<anonymous>)
     at performFetch (/Users/kraenhansen/Repositories/realm-studio/node_modules/realm/lib/user-methods.js:138:16)
     at _authenticate (/Users/kraenhansen/Repositories/realm-studio/node_modules/realm/lib/user-methods.js:337:19)
     at request.catch (/Users/kraenhansen/Repositories/realm-studio/node_modules/realm/lib/user-methods.js:341:20)
     at process._tickCallback (internal/process/next_tick.js:68:7)

@kneth
Copy link
Contributor

kneth commented Aug 12, 2019

Moreover, we should add support for exponential backoff and retrying for all platforms.

@kraenhansen
Copy link
Member Author

This issue went away as we merged with the Stich SDK and introduced the realm-network-transport package (https://github.com/realm/realm-js/tree/master/packages/realm-network-transport).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants