Fix error handling in worker
This commit is contained in:
parent
3ea59fbc17
commit
9b8eb488c3
@ -87,17 +87,16 @@ onmessage = async (message: OriginMessageEvent) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function handleErrors() {
|
function handleErrors() {
|
||||||
// eslint-disable-next-line no-restricted-globals
|
|
||||||
self.onerror = (e) => {
|
self.onerror = (e) => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(e);
|
console.error(e);
|
||||||
sendToOrigin({ type: 'unhandledError', error: { message: e.message || 'Uncaught exception in worker' } });
|
sendToOrigin({ type: 'unhandledError', error: { message: e.error.message || 'Uncaught exception in worker' } });
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line no-restricted-globals
|
|
||||||
self.addEventListener('unhandledrejection', (e) => {
|
self.addEventListener('unhandledrejection', (e) => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(e);
|
console.error(e);
|
||||||
sendToOrigin({ type: 'unhandledError', error: { message: e.reason || 'Uncaught rejection in worker' } });
|
sendToOrigin({ type: 'unhandledError', error: { message: e.reason.message || 'Uncaught rejection in worker' } });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,16 +77,16 @@ export default function createInterface(api: Record<string, Function>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleErrors() {
|
function handleErrors() {
|
||||||
self.onerror = (err) => {
|
self.onerror = (e) => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(err);
|
console.error(e);
|
||||||
sendToOrigin({ type: 'unhandledError', error: { message: 'Uncaught exception in worker' } });
|
sendToOrigin({ type: 'unhandledError', error: { message: e.error.message || 'Uncaught exception in worker' } });
|
||||||
};
|
};
|
||||||
|
|
||||||
self.addEventListener('unhandledrejection', (err) => {
|
self.addEventListener('unhandledrejection', (e) => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(err);
|
console.error(e);
|
||||||
sendToOrigin({ type: 'unhandledError', error: { message: 'Uncaught rejection in worker' } });
|
sendToOrigin({ type: 'unhandledError', error: { message: e.reason.message || 'Uncaught rejection in worker' } });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user