Repository navigation
|
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. |
Answered by
korywka
Apr 1, 2025
Replies: 2 comments
|
Looks like adding |
0 replies
Answer selected by
korywka
|
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();
}); |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like adding
error.preventDefault();helps to prevent Deno crashing. Kudos to ChatGPT and I wish Deno docs mention this too.