Skip to content

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

Closed
@asyncmax

Description

@asyncmax

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions