umi-server icon indicating copy to clipboard operation
umi-server copied to clipboard

prerender插件在编译报错时,能否被抓到

Open stoneyallen opened this issue 4 years ago • 0 comments

What happens?

prerender需要在ssr的node环境里编译好资源,如果在调用window对象的api时,例如window.location直接写成location,会导致build出错,但并不能被捕捉到,例如写了api.onBuildFail的插件,或者process.on('uncaughtException')去监听,都不能获取到报错事件,导致build出错提醒不可控。

以下是报错内容

(node:98854) UnhandledPromiseRejectionWarning: ReferenceError: history is not defined at Object.call (/Users/bytedance/Desktop/bytedance/ByteRangersFE/dist/src/app.ts:28:1) at require (/Users/bytedance/Desktop/bytedance/ByteRangersFE/dist/webpack/bootstrap:19:1) at Object.call (/Users/bytedance/Desktop/bytedance/ByteRangersFE/dist/src/pages/.umi-production/umi.js:28:13)

Expected behavior 1.希望提供一个报错的callback,能帮助捕捉prerender报错

Context

  • Umi Version 2.13.3:
  • Node Version 10:
  • Platform mac:

stoneyallen avatar May 18 '20 15:05 stoneyallen