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

Function name class when using Dexie and JSzip on same page due to setImmediate #1945

Open
davidhill001 opened this issue Apr 2, 2024 · 1 comment

Comments

@davidhill001
Copy link

When including both Dexie (with observable and syncable modules) and the JSZip library, the sync callback within Dexie seems to switch over to a function within the JSZip library which I believe causes the message "Sync Status changed: ERROR" to show in the console.

When looking at the console trace, it seems that it is pulling the setImmediate function from the JSzip library.

Is there anything that can be done to avoid this? I am including JSZip as it is required by DataTables.

image

Here is the setImmediate function from JSZip:

    function setImmediate(callback) {
      // Callback can either be a function or a string
      if (typeof callback !== "function") {
        callback = new Function("" + callback);
      }
      // Copy function arguments
      var args = new Array(arguments.length - 1);
      for (var i = 0; i < args.length; i++) {
          args[i] = arguments[i + 1];
      }
      // Store and register the task
      var task = { callback: callback, args: args };
      tasksByHandle[nextHandle] = task;
      registerImmediate(nextHandle);
      return nextHandle++;
    }
@dfahlander
Copy link
Collaborator

The old dexie-observable / dexie-syncable addons does use setImmediate in case it is present on the global object to fire off queue consumer. Probably JSzip puts its setImmediate onto the global object / window / self, making the addons pick it up. There's nothing we can do in the addons to avoid it, but if JSZip isn't dependent on setting it on the global objects, one way would be to delete setImmediate from the global object after importing JSZip (just speculations)

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

No branches or pull requests

2 participants