web-infra-dev / rsbuild

The Rspack-based build tool. It's fast, out-of-the-box and extensible.
https://rsbuild.dev/
MIT License
1.82k stars 140 forks source link

[Bug]: Invalid WebSocket Frame: RSV1 must be clear #1541

Closed vacekj closed 9 months ago

vacekj commented 9 months ago

Version

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 7.05 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Brave Browser: 121.1.62.156
    Chrome: 121.0.6167.139
    Safari: 17.2.1
  npmPackages:
    @rsbuild/core: ^0.4.1 => 0.4.1 
    @rsbuild/plugin-react: ^0.3.11 => 0.3.11 
    @rsbuild/plugin-svgr: ^0.3.11 => 0.3.11

Details

The dev server crashes with the message:

node:events:497
      throw er; // Unhandled 'error' event
      ^

RangeError: Invalid WebSocket frame: RSV1 must be clear
    at Receiver.getInfo (/Users/vacekj/Programming/grants-round/node_modules/.pnpm/@rsbuild+core@0.4.1/node_modules/@rsbuild/core/compiled/ws/index.js:1:15302)
    at Receiver.startLoop (/Users/vacekj/Programming/grants-round/node_modules/.pnpm/@rsbuild+core@0.4.1/node_modules/@rsbuild/core/compiled/ws/index.js:1:14714)
    at Receiver._write (/Users/vacekj/Programming/grants-round/node_modules/.pnpm/@rsbuild+core@0.4.1/node_modules/@rsbuild/core/compiled/ws/index.js:1:14114)
    at writeOrBuffer (node:internal/streams/writable:564:12)
    at _write (node:internal/streams/writable:493:10)
    at Writable.write (node:internal/streams/writable:502:10)
    at Socket.socketOnData (/Users/vacekj/Programming/grants-round/node_modules/.pnpm/@rsbuild+core@0.4.1/node_modules/@rsbuild/core/compiled/ws/index.js:1:48239)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
Emitted 'error' event on WebSocket instance at:
    at Receiver.receiverOnError (/Users/vacekj/Programming/grants-round/node_modules/.pnpm/@rsbuild+core@0.4.1/node_modules/@rsbuild/core/compiled/ws/index.js:1:47301)
    at Receiver.emit (node:events:519:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'WS_ERR_UNEXPECTED_RSV_1',
  [Symbol(status-code)]: 1002
}

Node.js v21.6.0

Reproduce link

https://github.com/gitcoinco/grants-stack

Reproduce Steps

download the repo, branch performance go to packages/round-manager pnpm i && pnpm rsbuild dev visit the site in browser and wait for a few minutes observe the dev server crashing and the error message.

xc2 commented 9 months ago

would you please try serving on port 8081 or any port other than 8080?

vacekj commented 9 months ago

This indeed fixes it, I guess it was some other application conflicting with it. Maybe some IRC client, from my brief google search. Defaulting the port to 3000 is fine.

chenjiahan commented 7 months ago

Default server port to 3000 in Rsbuild v0.6.0: https://github.com/web-infra-dev/rsbuild/discussions/1970#discussioncomment-9056148