Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js HMR websocket n.write is not a function #21979

Closed
littledivy opened this issue Jan 18, 2024 · 0 comments · Fixed by #21984
Closed

Next.js HMR websocket n.write is not a function #21979

littledivy opened this issue Jan 18, 2024 · 0 comments · Fixed by #21984
Labels
bug Something isn't working correctly node compat

Comments

@littledivy
Copy link
Member

To reproduce:

  1. mkdir repro && cd repro
  2. deno run -A --unstable npm:degit 'timlrx/tailwind-nextjs-starter-blog'
  3. Convert next.config.js to ESM
  4. npm i
  5. deno run -A --unstable-byonm ./node_modules/.bin/next dev
  6. Visit http://localhost:3000

In the wall of errors, you'll find:

Error handling upgrade request TypeError: n.write is not a function
    at WebSocketServer.completeUpgrade (file:///Users/divy/gh/demo/node_modules/next/dist/compiled/ws/index.js:1:31537)
    at WebSocketServer.handleUpgrade (file:///Users/divy/gh/demo/node_modules/next/dist/compiled/ws/index.js:1:30712)
    at HotReloader.onHMR (file:///Users/divy/gh/demo/node_modules/next/src/server/dev/hot-reloader-webpack.ts:365:14)
    at upgradeHandler (file:///Users/divy/gh/demo/node_modules/next/src/server/lib/router-server.ts:579:49)
    at ServerImpl.<anonymous> (file:///Users/divy/gh/demo/node_modules/next/src/server/lib/start-server.ts:176:13)
    at ServerImpl.emit (ext:deno_node/_events.mjs:383:28)
    at handler (node:http:1287:14)
    at ext:deno_http/00_serve.js:460:24
    at ext:deno_http/00_serve.js:694:29
    at eventLoopTick (ext:core/01_core.js:182:7)
@littledivy littledivy added bug Something isn't working correctly node compat labels Jan 18, 2024
littledivy added a commit that referenced this issue Jan 18, 2024
Update the `req.socket` to be a `net.Socket` from `FakeSocket`

Fixes #21979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant