Skip to content

fix(dev-server-core): reject websocket failures before open - #3178

Open
sean0407 wants to merge 1 commit into
modernweb-dev:masterfrom
sean0407:codex/web-3158-websocket-open-failure-20261021
Open

sean0407 wants to merge 1 commit into
modernweb-dev:masterfrom
sean0407:codex/web-3158-websocket-open-failure-20261021

Conversation

@sean0407

Copy link
Copy Markdown

Fixes #3158

Why

When the browser websocket closes or errors before opening, webSocketOpened never settles. sendMessage() then remains pending and the test runner eventually reports only that browser tests did not start.

Reproduction

Run the web-sockets test with an injected websocket, close the browser-side socket before its open event, then send a wtr-session-started message. Before this change, the regression test timed out because sendMessage() never settled. With the fix, the test receives the websocket connection error immediately.

Changes

  • Reject the open wait when the websocket errors or closes before opening, and remove the listeners after either success or failure.
  • Add a regression test that runs the served client module and closes a fake websocket before opening.

Checks

  • npm run build --workspace=@web/parse5-utils — passed.
  • npm run build --workspace=@web/dev-server-core — passed.
  • node --experimental-strip-types --test --test-force-exit test/web-sockets/webSocketsPlugin.test.ts from packages/dev-server-core — passed (5 tests).
  • Prettier check on both changed files — passed.
  • ESLint on both changed files — passed.
  • git diff --check — passed.

@changeset-bot

changeset-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6672f8a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

sendMessage awaits a promise that can never reject, so a websocket that fails to open reports only "Browser tests did not start"

1 participant