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

[BUG] 'ReferenceError: setImmediate is not defined' on the browser #249

Closed
asyncmax opened this issue Aug 6, 2020 · 4 comments
Closed
Labels

Comments

@asyncmax
Copy link

asyncmax commented Aug 6, 2020

Expected Behavior

DataLoader should gracefully fall back to setTimeout if setImmediate is not supported on the browser.

Current Behavior

It crashes with an error ReferenceError: setImmediate is not defined.

Possible Solution

setImmediate || setTimeout;

-    setImmediate || setTimeout;
+   typeof setImmediate === 'function' ?
+      setImmediate :
+      (fn => {setTimeout(fn, 0);});

This code also fixes a problem of calling setTimeout without a delay number when it falls back.
Sorry, I didn't create a PR as I am not familiar with the Flow typing that this project is based on.

@asyncmax asyncmax added the bug label Aug 6, 2020
@Discordius
Copy link

This appears to also be breaking my build.

@DoneDeal0
Copy link

Adding Yuzu's polyfill fixed the issue for me: https://github.com/YuzuJS/setImmediate/blob/master/setImmediate.js

On top of index.ts/js or at the top of your file(s) that use dataloader, just add:

import "setimmediate";

@nanto
Copy link

nanto commented Apr 28, 2021

Since setImmediate is no longer on a standard track and latest major browsers don't implement it (IE 11 is no longer a "major browser"), I think it is better if we can run dataloader on browsers without setImmediate polyfill.

silentsakky added a commit to Zimbra/zm-api-js-client that referenced this issue Jun 10, 2021
silentsakky added a commit to Zimbra/zm-api-js-client that referenced this issue Jun 23, 2021
silentsakky added a commit to Zimbra/zm-api-js-client that referenced this issue Jul 20, 2021
silentsakky added a commit to Zimbra/zm-api-js-client that referenced this issue Feb 14, 2022
@saihaj saihaj mentioned this issue Mar 11, 2022
26 tasks
@saihaj
Copy link
Member

saihaj commented Mar 25, 2022

#293

@saihaj saihaj closed this as completed Mar 25, 2022
silentsakky added a commit to Zimbra/zm-api-js-client that referenced this issue May 27, 2022
silentsakky added a commit to Zimbra/zm-api-js-client that referenced this issue Feb 24, 2023
silentsakky added a commit to Zimbra/zm-api-js-client that referenced this issue Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants