reactjs / server-components-demo

Demo app of React Server Components.
https://reactjs.org/server-components
MIT License
4.27k stars 640 forks source link

fix: issue of "fetch is not defined" when using docker #67

Closed xc1427 closed 1 year ago

xc1427 commented 1 year ago

Because fetch does not exist in early version of node (like 14.x)

Then if running up by docker compose, we see errors below,

Application Error
ReferenceError: fetch is not defined
    at Note (/opt/notes-app/src/Note.js:36:24)
    at attemptResolveElement (/opt/notes-app/node_modules/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js:1597:18)
    at resolveModelToJSON (/opt/notes-app/node_modules/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js:1883:21)
    at Object.toJSON (/opt/notes-app/node_modules/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js:1421:14)
    at stringify (<anonymous>)
    at processModelChunk (/opt/notes-app/node_modules/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js:258:14)
    at retryTask (/opt/notes-app/node_modules/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js:2166:26)
    at performWork (/opt/notes-app/node_modules/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js:2213:7)
    at async_hooks.js:313:14
    at AsyncResource.runInAsyncScope (async_hooks.js:197:9)
    at AsyncLocalStorage.run (async_hooks.js:311:35)
    at Immediate.<anonymous> (/opt/notes-app/node_modules/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js:2313:29)
    at processImmediate (internal/timers.js:461:21)
    at process.callbackTrampoline (internal/async_hooks.js:131:14)
image
gaearon commented 1 year ago

thanks but we assume latest node anyway so i’ll close this and merge the other one