Skip to content

test: make websocket diagnostics ping-pong ordering deterministic#5222

Merged
mcollina merged 2 commits into
nodejs:mainfrom
trivikr:test-diagnostics-channel-ping-pong
May 6, 2026
Merged

test: make websocket diagnostics ping-pong ordering deterministic#5222
mcollina merged 2 commits into
nodejs:mainfrom
trivikr:test-diagnostics-channel-ping-pong

Conversation

@trivikr

@trivikr trivikr commented May 6, 2026

Copy link
Copy Markdown
Member

This relates to...

Fixes: #5200

Rationale

The test created the client WebSocket before subscribing to the diagnostics channels and before registering the server connection handler. Since the constructor starts the connection immediately, the server could send ping, pong, and close before the test was fully set up.

Diagnostics channels are also process-global, so the test should ignore ping/pong events from other websocket instances.

Changes

  • Subscribe to undici:websocket:ping and undici:websocket:pong before creating the client WebSocket.
  • Register the server connection handler before creating the client WebSocket.
  • Filter diagnostics events so the test only asserts events for its own WebSocket instance.

Features

N/A

Bug Fixes

N/A

Breaking Changes and Deprecations

N/A

Status

Assisted-by: openai:gpt-5.5

Assisted-by: openai:gpt-5.5
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
@codecov-commenter

codecov-commenter commented May 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.27%. Comparing base (4f8f814) to head (e13b37d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5222   +/-   ##
=======================================
  Coverage   93.27%   93.27%           
=======================================
  Files         110      110           
  Lines       36366    36366           
=======================================
  Hits        33922    33922           
  Misses       2444     2444           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit 116e38c into nodejs:main May 6, 2026
35 checks passed
@trivikr trivikr deleted the test-diagnostics-channel-ping-pong branch May 6, 2026 21:46
@github-actions github-actions Bot mentioned this pull request May 14, 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.

[flaky] test\websocket\diagnostics-channel-ping-pong.js

3 participants