wasm-node: don't open a substream on a closed connection - #3327
Merged
lrubasze merged 2 commits intoAug 5, 2026
Conversation
lexnv
approved these changes
Aug 5, 2026
skunert
approved these changes
Aug 5, 2026
bkchr
approved these changes
Aug 5, 2026
lrubasze
deleted the
lrubasze/fix-open-substream-on-closed-peer-connection
branch
August 5, 2026 16:17
Merged
lrubasze
added a commit
that referenced
this pull request
Aug 7, 2026
This is to: - publish `smoldot-v3.4.0` npm. - publish crates `smoldot-light v2.0.0`, `smoldot v2.2.0` ## Changes ### Added - Implement the [RFC-0163](https://github.com/polkadot-fellows/RFCs/blob/main/text/0163-ec-host-functions.md) elliptic curve host functions: scalar multiplication and multi-scalar multiplication on bandersnatch (`ed_on_bls12_381_bandersnatch`), and scalar multiplication, multi-scalar multiplication, multi Miller loop and final exponentiation on BLS12-381. This lets smoldot execute runtimes that verify bandersnatch ring-VRF proofs (proof-of-personhood chains). The remaining RFC-0163 functions (Pallas, Vesta) are registered but unimplemented. ([#3331](#3331); fixes [#3328](#3328)) ### Fixed - Fix a panic (`assertion failed: task.event_pending_send.is_none()` in debug builds) or a silently lost connection event (release builds, later causing a sync service panic on an unmatched `Disconnected`) when a peer ban raced with a network event that was still being delivered to subscribers. ([#3314](#3314); fixes [#3312](#3312)) - No longer crash with an uncaught `InvalidStateError` when sending on an `RTCDataChannel` that left the `open` state before its `close` event was delivered; the send is skipped, since the pending `close` event resets the stream anyway. ([#3324](#3324); fixes [#3322](#3322)) - In remote-instance mode, no longer crash with an uncaught `TypeError` when a message addressed to the first substream of a WebRTC connection (stream id 0) raced with that substream's reset: stream id 0 was accidentally exempt from the stale-message check. ([#3326](#3326); related to [#3322](#3322)) - No longer crash with an uncaught `InvalidStateError` when opening a substream on an `RTCPeerConnection` that moved to `closed` before its `connectionstatechange` event was delivered. ([#3327](#3327); fixes [#3325](#3325)) - Fix a panic in the connection task when the remote resets an inbound notifications substream while a message about that substream is still in flight (a duplicate reject, or a close right after an accept). ([#3329](#3329); fixes [#3304](#3304))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3325
Fixes DOTLI-B9
Problem
An
RTCPeerConnectioncan move toclosedbefore itsconnectionstatechangeevent is dispatched. Until the event runs, smoldot still believes the connection is alive and can ask to open a substream;createDataChannel()then throws an uncaughtInvalidStateError. Connection-level twin of #3322, observed in production (smoldot 3.3.2, Chrome 151, Sentry DOTLI-B9).Fix
openOutSubstreamis now a no-op whensignalingStateisclosed— the pending state-change event resets the connection anyway. Same shape as the send guard from #3324.Test
New browser-only e2e test
webrtc_open_after_pc_close: closes one connection mid-substream-burst and delivers the state-change notification 2s late (browsers fire no events for a localclose(), so the late event is synthesized), so smoldot's nextopenOutSubstreamlands on a closed connection. Without the guard the client crashes; with it it must sync normally. A wrappedsignalingStategetter asserts the race was actually exercised. CI entry commented out until browser test execution is re-enabled (as with the otherwebrtc_*tests).