Skip to content

ports/webrtc: latch owned channels on peer-connection close - #36

Merged
lann merged 1 commit into
mainfrom
fast-fish
Aug 10, 2026
Merged

ports/webrtc: latch owned channels on peer-connection close#36
lann merged 1 commit into
mainfrom
fast-fish

Conversation

@lann

@lann lann commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Found running polymorph-webrtc-datachannels' driver-ct loopback suite under the upstreamed copy of this port (the #19 run, delivered as polymorph-webrtc-datachannels#149): PeerConnection.close() closed only the native channels, so a post-close send could still observe readyState === "open" inside node-datachannel's asynchronous transition window — their solo/post-close-send case races its 1000-send bound against the 1 s close-drain and failed intermittently under the callback ABI's await cadence (JSPI's slower awaits hide the same latent race in their jco-impl reference, noted in their PR).

close() now closes the owned channels through their DataChannel wrappers, whose local-close flag is the synchronous gate the WIT contract's "observed locally at once" requires — the same discipline DataChannel.close() already applies to its own resource. Regression test added (first post-close send fails closed, on the locally created and the incoming channel alike).

Also: docs/consumers.md's webrtc row gains the conformance-matrix gate reference.

Gate: just test-webrtc — 10/10 on the dev box (the authoritative environment per #21).

Found running polymorph-webrtc-datachannels' driver-ct loopback suite
under the upstreamed copy of this port (the #19 run, delivered as their
PR #149): PeerConnection.close() closed only the native channels, so a
post-close send could still observe readyState "open" inside
node-datachannel's asynchronous transition window — their
solo/post-close-send case raced its 1000-send bound against the 1 s
close-drain and failed intermittently under the callback ABI's await
cadence (JSPI's slower awaits hide the same latent race in their
jco-impl reference).

close() now closes the owned channels through their DataChannel
wrappers, whose local-close flag is the synchronous gate the WIT
contract's "observed locally at once" requires — the same discipline
DataChannel.close() already applies. Regression test added; docs:
consumers.md webrtc row gains the conformance-matrix gate.

Gate: just test-webrtc (10/10).
@lann
lann merged commit 5f718cd into main Aug 10, 2026
4 checks passed
lann added a commit that referenced this pull request Aug 10, 2026
The runner-networking theory is disproven and the actual defects are
fixed (#36, #37, root-caused via polymorph-webrtc-datachannels#149's
probe matrix): the unit-test timeouts were a candidate-buffering race in
the tests' own connectPair helper, and the exit-path SIGSEGV was the
addon's thread joins racing isolate teardown after cleanup(). Both fixes
are runner-validated (deno task test exits 0 on ubuntu-latest in the
consumer repo, and their Conformance matrix job runs the same suite
class green). Drop the tolerated wrapper and the stale rationale
comments.

Gate: just test-webrtc.
lann added a commit that referenced this pull request Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant