geelen / react-snapshot

A zero-configuration static pre-renderer for React apps
MIT License
1.66k stars 104 forks source link

Use of WebSocket breaks crawler #118

Open zwass opened 5 years ago

zwass commented 5 years ago

When working with a component that opens a Websocket:

🕷   Starting crawling http://localhost:61974/
Error: Uncaught [ReferenceError: WebSocket is not defined]
    at reportException (/Users/zwass/dev/try-osquery/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:58:24)
    at processJavaScript (/Users/zwass/dev/try-osquery/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:130:7)
    at HTMLScriptElementImpl._eval (/Users/zwass/dev/try-osquery/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:65:7)
    at /Users/zwass/dev/try-osquery/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:31:22
    at Object.check (/Users/zwass/dev/try-osquery/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:89:11)
    at Object.check (/Users/zwass/dev/try-osquery/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:92:23)
    at /Users/zwass/dev/try-osquery/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:108:12
    at wrappedEnqueued (/Users/zwass/dev/try-osquery/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:255:16)
    at Request.request [as _callback] (/Users/zwass/dev/try-osquery/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:203:9)
    at Request.self.callback (/Users/zwass/dev/try-osquery/node_modules/request/request.js:185:22) ReferenceError: WebSocket is not defined
    at new t (http://localhost:61974/static/js/main.c345f012.chunk.js:1:495)
    at s (http://localhost:61974/static/js/1.bc8d6ca8.chunk.js:1:157233)
    at re (http://localhost:61974/static/js/1.bc8d6ca8.chunk.js:1:158420)
    at e.render (http://localhost:61974/static/js/1.bc8d6ca8.chunk.js:1:160797)
    at e.read (http://localhost:61974/static/js/1.bc8d6ca8.chunk.js:1:160411)
    at Object.renderToString (http://localhost:61974/static/js/1.bc8d6ca8.chunk.js:1:165177)
    at t.render (http://localhost:61974/static/js/1.bc8d6ca8.chunk.js:1:35884)
    at Module.76 (http://localhost:61974/static/js/main.c345f012.chunk.js:1:1492)
    at f (http://localhost:61974/:1:518)
    at Object.28 (http://localhost:61974/static/js/main.c345f012.chunk.js:1:87)
🔥 'render' from react-snapshot was never called. Did you replace the call to ReactDOM.render()?
🕸   Finished crawling.
natansevero commented 2 years ago

I am facing the same issue

natansevero commented 2 years ago

As I said, I was facing the same issue. The solution was to replace the react-snapshot for react-snap. The react-snap works with applications that use WebSocket implementation.