stereobooster / react-snap

πŸ‘» Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.05k stars 394 forks source link

UnhandledPromiseRejectionWarning Error: Execution context was destroyed, most likely because of a navigation. #521

Open gprasanth24k opened 3 years ago

gprasanth24k commented 3 years ago

on npm run build

this is the error it is throwing someone please help!

βœ… crawled 11 out of 28 (/aig-cyberedge/) βœ… crawled 12 out of 28 (/resource/post/march-newsletter-stay-up-to-date-on-cyber-trends-with-bandura-2) πŸ”₯ UnhandledPromiseRejectionWarning Error: Execution context was destroyed, most likely because of a navigation. at rewriteError (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/ExecutionContext.js:167:15) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:93:5) at async ExecutionContext._evaluateInternal (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/ExecutionContext.js:120:56) at async ExecutionContext.evaluate (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/ExecutionContext.js:48:12) at async Page. (/Users/admin/Projects/Bandura/bandura-website/node_modules/react-snap/index.js:214:7) -- ASYNC -- at ExecutionContext. (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/helper.js:111:15) at DOMWorld.evaluate (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/DOMWorld.js:112:20) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:93:5) -- ASYNC -- at Frame. (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/helper.js:111:15) at Page.evaluate (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/Page.js:833:43) at Page. (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/helper.js:112:23) at Page. (/Users/admin/Projects/Bandura/bandura-website/node_modules/react-snap/index.js:214:18) at Page.emit (events.js:327:22) at NetworkManager. (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/Page.js:111:69) at NetworkManager.emit (events.js:315:20) at NetworkManager._onResponseReceived (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/NetworkManager.js:272:10) at CDPSession.emit (events.js:315:20) at CDPSession._onMessage (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/Connection.js:200:12) -- ASYNC -- at Page. (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/helper.js:111:15) at Page. (/Users/admin/Projects/Bandura/bandura-website/node_modules/react-snap/index.js:214:18) at Page.emit (events.js:327:22) at NetworkManager. (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/Page.js:111:69) at NetworkManager.emit (events.js:315:20) at NetworkManager._onResponseReceived (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/NetworkManager.js:272:10) at CDPSession.emit (events.js:315:20) at CDPSession._onMessage (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/Connection.js:200:12) at Connection._onMessage (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/Connection.js:112:17) at WebSocket. (/Users/admin/Projects/Bandura/bandura-website/node_modules/puppeteer/lib/WebSocketTransport.js:44:24) βœ… crawled 13 out of 28 (/resource/post/bandura-threatconnect-proactively-block-threats-using-threat-intelligence) βœ… crawled 33 out of 35 (/integrations/) βœ… crawled 34 out of 35 (/about-us/)

HWideman commented 2 years ago

We just fixed a similar issue caused by react-snap attempting to crawl redirects we had in react-router.

      <Route
        exact
        path="/<route>"
        component={() => {
          if (navigator.userAgent !== "ReactSnap") {
            window.location.replace('<redirect>');
          }
          return null;
        }}
      />
phuochau commented 2 years ago

I can confirm @HWideman solution can solve the issue