Skip to content

fix: buffer emitWithAck until (re)connect - #80

Merged
electrohyun merged 2 commits into
mainfrom
fix/emitwithack-buffering
Jul 30, 2026
Merged

fix: buffer emitWithAck until (re)connect#80
electrohyun merged 2 commits into
mainfrom
fix/emitwithack-buffering

Conversation

@electrohyun

Copy link
Copy Markdown
Owner

Summary

ClientSocket.emit buffers when not connected and replays on (re)connect, but emitWithAck sent to this.serverSocket directly. While disconnected that delivered to the dead previous socket and leaked the pending-ack rejecter; before the first connect it dereferenced an undefined socket.

This adds the same not-connected guard to emitWithAck: it buffers the call (with its trailing ack callback) into sendBuffer, so completeConnection replays it to the (re)connected socket and the ack still settles, matching socket.io-client.

Related issue

Closes #57

Checklist

  • Tests added or updated
  • Behavior verified against real socket.io

The new conformance test in ack.test.ts was pinned against the real target first (it passes there) and failed on the mock before the fix. Both targets are green now.

ClientSocket.emit buffers when not connected and replays on (re)connect, but
emitWithAck sent to this.serverSocket directly. While disconnected that
delivered to the dead previous socket and leaked the pending-ack rejecter;
before the first connect it dereferenced an undefined socket. Add the same
not-connected guard: buffer the call with its trailing ack callback into
sendBuffer, so completeConnection replays it to the (re)connected socket and the
ack still settles, matching socket.io-client.
Pin the socket.io-client behavior first: an emitWithAck issued while
disconnected buffers and settles after reconnect. Passes on the real target and
failed on the mock before the fix.
@electrohyun electrohyun added this to the v0.2.0 milestone Jul 30, 2026
@electrohyun electrohyun added the bug Something isn't working label Jul 30, 2026
@electrohyun electrohyun self-assigned this Jul 30, 2026
@electrohyun
electrohyun merged commit f4ba2b9 into main Jul 30, 2026
2 checks passed
@electrohyun
electrohyun deleted the fix/emitwithack-buffering branch July 30, 2026 06:22
@electrohyun electrohyun removed this from the v0.2.0 milestone Aug 3, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in smocket Aug 3, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in smocket Aug 3, 2026
@electrohyun electrohyun added the 📏 s Pull request changes 10–49 lines label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 📏 s Pull request changes 10–49 lines

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

emitWithAck is not buffered before connect or while disconnected

1 participant