Skip to content

feat: support ws connection states and byte payloads #540

Done
5 of 5 issues completed
Done

Description

@electrohyun

Problem

ws applications use connection states, send callbacks, close information, and byte payloads as well as text. Support these behaviors on top of #539, within the API scope in the v2 direction.

Proposed API

client.send(new Uint8Array([1, 2, 3]));
client.send('next message');
client.close(1000, 'done');

socket.send('reply', (error) => {
  if (error) console.error(error);
});

Socket.IO behavior

Socket.IO ACK and disconnect behavior should remain unchanged. Follow real ws for callbacks, connection states, close validation, and lifecycle events. A send callback indicates send completion, not peer receipt.

Scope check

  • This is not reconnection, transport fallback, heartbeat, Redis multi-server, or binary encoding

Tasks

  • Support state-dependent send errors and callbacks, close codes/reasons, terminate, and server.close.
  • Handle connection failure, including valid wss: targets against plain servers, and cleanup while work is pending.
  • Support the text and byte inputs defined in feat: define ws usage and public types #555, preserve byte-view offsets and lengths, and support binaryType values nodebuffer and arraybuffer.
  • Compare message ordering and send followed by close for supported payloads with real ws.
  • Update types and document supported payloads and observable differences.

Closing a server must preserve its established clients as ws does, and cleanup must leave no pending sockets or work. Blob and TLS servers are outside this scope. Byte payload handling does not include wire encoding or transport backpressure.

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions