fix: handle unhandled promise rejections (#2568)

This commit is contained in:
Niklas von Hertzen
2021-07-12 19:01:43 +08:00
committed by GitHub
parent 382853cb33
commit 4555940d0b
6 changed files with 181 additions and 45 deletions

View File

@ -86,6 +86,11 @@ testList
throw new Error('Window not found for iframe');
}
contentWindow.addEventListener('unhandledrejection', (event) => {
console.error(event.reason);
throw new Error(`unhandledrejection: ${JSON.stringify(event.reason)}`);
});
const canvas: HTMLCanvasElement = await contentWindow
// @ts-ignore
.html2canvas(contentWindow.forceElement || contentWindow.document.documentElement, {