Skip to content

fix(ext/node): don't fire http2 settings callback after session destroy#36230

Open
crowlbot wants to merge 2 commits into
mainfrom
fix/flaky-test-http2-ping-settings-heapdump
Open

fix(ext/node): don't fire http2 settings callback after session destroy#36230
crowlbot wants to merge 2 commits into
mainfrom
fix/flaky-test-http2-ping-settings-heapdump

Conversation

@crowlbot

Copy link
Copy Markdown
Contributor

Fixes #36141.

node_compat::parallel::test-http2-ping-settings-heapdump.js fails intermittently on macos-aarch64, recurring across independent commits and surviving the runner's built-in flaky-retry.

Root cause. The test (a regression test for nodejs/node#28088) runs two variants. For the settings variant it does:

session.settings(undefined, common.mustNotCall());
// ...
session.destroy();

i.e. after destroying the session, the pending settings ACK callback must not fire. In this polyfill the two acknowledgement paths are asymmetric:

  • PING callbacks are tracked in state.pendingPings and cancelled atomically in closeSession() on destroy (the array is emptied, so a late PONG delivered to onPing finds nothing). Deterministic.
  • SETTINGS callbacks (settingsCallback) are bound directly onto the session handle with no destroy guard. The handle's SETTINGS_ACK dispatch isn't guaranteed to be torn down synchronously with session.destroy(), so a SETTINGS_ACK arriving in the window right after destroy still invokes the user callback — tripping mustNotCall(). Whether the ACK or the teardown wins is timing-dependent, which is why it only shows up on slower runners.

Fix. Guard settingsCallback so a destroyed session never invokes the user callback. This mirrors Node's Http2Session::Close (src/node_http2.cc), which detaches the pending Http2Settings (dropping its callback) rather than running it, and makes the settings path deterministic on destroy just like the ping path already is.

The change is defensive and Node-matching: on a live (non-destroyed) session, legitimate settings ACKs still fire as before.

The http2 settings ACK callback (settingsCallback) was registered directly on
the session handle with no guard against the session already being destroyed.
Unlike pending PINGs — which closeSession() cancels atomically on destroy — a
SETTINGS_ACK that arrives in the window after session.destroy() would still
invoke the user's settings callback, because the handle's ACK dispatch isn't
guaranteed to be torn down synchronously with destroy().

This matches Node's Http2Session::Close (src/node_http2.cc), which detaches the
pending Http2Settings (dropping its callback) rather than running it. Guard
settingsCallback so a destroyed session never invokes the user callback.

Fixes the intermittent failure of the mustNotCall() settings callback in
node_compat parallel/test-http2-ping-settings-heapdump.js on slower runners
(seen on macos-aarch64).

Closes #36141
@crowlbot
crowlbot requested a review from crowlKats July 22, 2026 04:39
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: node_compat::parallel::test-http2-ping-settings-heapdump.js fails on macos-aarch64

1 participant