Skip to content

WebSockets #1811

Description

@KhafraDev

permessage-deflate support

  • Is this something we need/want to support? Servers that are setup correctly should work even if the client doesn't support it.
  • Memory fragmentation issues when using zlib?
  • Added complexity of decompressing frames asynchronously

Performance

  • Consume the least amount of bytes possible, rather than concatenating every chunk available. See ws' implementation. Fixed in 5165d67
  • Switch to Buffer.allocUnsafe in lib/websocket/frame.js Fixed in b6844f0
  • Handle TODO comments labeled as "optimize this".
  • Benchmarks
  • Use FastBuffer (Buffer[Symbol.species])

Tests

  • Add ws' test suite. Note this isn't easy because ws' api does not strictly follow the spec and it occasionally uses internal, underscored properties. Also note that a lot of the validation tests are already handled by the WPTs.
  • Autobahn testsuite
  • 100% code coverage for lib/websockets Code coverage is high enough; WPTs are not counted, which make up a majority of the tests.
  • Test more strange/error conditions:
    • Chunks that contain thousands of frames
    • Chunks that receive a pong/close frame in the middle of a fragmented message (Control frames are already handled the same.)
    • Sending invalid frames

Bugs

  • using WebSocket.send with a Blob asynchronously writes the blob data to the socket. This can cause issues when concurrently sending a blob with anything else. Note: we need support in node core to read a Blob synchronously.
  • ByteParser.run runs recursively, meaning the max call stack can be exceeded under certain conditions (ie. receiving thousands of frames in a single chunk). Fixed in 1b858fb

Features

  • Setting an undici Dispatcher rather than using the global dispatcher by default.
  • Letting the client generate the mask for performance reasons.

WebSocketStream

Metadata

Metadata

Assignees

No one assigned

    Labels

    websocketPull requests or issues related to websocket and its standard

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions