8000 Add an event listener for unhandledrejections? · Issue #3 · dumbmatter/promise-worker-bi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
7FFF
Add an event listener for unhandledrejections? #3
Open
@ejdaly

Description

@ejdaly

Hi,

Thanks for the library.

I can see there is an event listener to catch global "error" events, but not on global "unhandledrejection" events.

E.g if my worker code does something like below, it won't get handled by the registerError callback.

const test = function() {
  return new Promise(function(resolve, reject) {
    setTimeout(() => {
      reject(new Error("test error"))
      }, 5000);
    })
}

test();

Would it make sense to add a global listener for that, e.g. could just "re-throw" that error

self.addEventListener("unhandledrejection", function (e) {
  e.preventDefault();
  throw e.reason;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0