-
When we worker = new Worker(new URL('./worker.ts', import.meta.url).href, {
type: 'module',
});
worker.onerror = (error) => {
console.error(error);
}; What is the correct way to handle worker errors for Deno? Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Looks like adding |
Beta Was this translation helpful? Give feedback.
-
I think another way to handle worker errors in Deno is to place this within the worker script: self.addEventListener("unhandledrejection", (event) => {
console.error("Unhandled rejection:", event.reason);
event.preventDefault();
// Terminate the worker manually if you want to:
// self.close();
}); |
Beta Was this translation helpful? Give feedback.
Looks like adding
error.preventDefault();
helps to prevent Deno crashing. Kudos to ChatGPT and I wish Deno docs mention this too.