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