Skip to content

fix(run-server): handle malformed JSON frames without crashing#40121

Open
yury-s wants to merge 1 commit intomicrosoft:mainfrom
yury-s:fix-run-server-malformed-json
Open

fix(run-server): handle malformed JSON frames without crashing#40121
yury-s wants to merge 1 commit intomicrosoft:mainfrom
yury-s:fix-run-server-malformed-json

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented Apr 9, 2026

Summary

  • run-server crashed on a single malformed WebSocket text frame because JSON.parse in the message listener was unprotected, turning a SyntaxError into an unhandled rejection that terminated the process — a pre-auth DoS when the endpoint is exposed beyond localhost.
  • Catch the parse error, close the offending connection with WebSocket code 1007 (invalid frame payload data), and keep the server running.
  • Added a regression test that sends ] on a raw WebSocket and then reconnects via browserType.connect to verify the server is still alive.

A malformed WebSocket text frame caused JSON.parse to throw an
uncaught SyntaxError from the async message listener, terminating
the run-server process. Catch the parse error, close the offending
connection with code 1007, and keep the server running.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Test results for "tests 1"

8 flaky ⚠️ [chromium-library] › library/video.spec.ts:118 › screencast › should capture static page `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-library] › library/video.spec.ts:342 › screencast › should work for popups `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-library] › library/video.spec.ts:342 › screencast › should work for popups `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:724 › screencast › should work with video+trace `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-page] › page/page-request-continue.spec.ts:754 › propagate headers cross origin redirect after interception `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:342 › screencast › should work for popups `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/video.spec.ts:724 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node20`
⚠️ [webkit-page] › page/page-set-input-files.spec.ts:38 › should upload a folder `@webkit-ubuntu-22.04-node20`

39196 passed, 846 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Test results for "MCP"

6468 passed, 383 skipped


Merge workflow run.

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.

2 participants