fix(ext/node): use node:timers for http server connection checks, expo#33483
Conversation
|
|
||
| const interval = this.connectionsCheckingInterval || 30_000; | ||
| this[kConnectionsCheckingInterval] = core.createSystemInterval( | ||
| this[kConnectionsCheckingInterval] = setInterval( |
There was a problem hiding this comment.
This will cause sanitizer issues in tests. The previous code was correct
fibibot
left a comment
There was a problem hiding this comment.
LGTM. The follow-up commit (b8a62128, "fix sanitizer leak: wrap createSystemInterval handle for _destroyed") replaces the bare core.createSystemInterval ID with a ConnectionsCheckingInterval wrapper class ({ _timerId, _destroyed }), which both addresses the sanitizer leak @bartlomieju raised on the prior round and gives the upstream test the _destroyed property it asserts on:
setupConnectionsTracking()→destroyConnectionsCheckingInterval(old)→core.createSystemInterval(...)→ store new handle. The destroy helper no-ops whenhandle._destroyed, so a re-listen path doesn't double-cancel.httpServerPreClose(server)calls the same destroy helper, so closing the server cancels the underlying timer and flips_destroyed = true. The previous code zeroedserver[kConnectionsCheckingInterval]after cancelling; the new code leaves the (now-destroyed) handle in place because the upstream test readsserver[kConnectionsCheckingInterval]._destroyedafter close.kConnectionsCheckingIntervalis now exported from_http_server, matchingrequire('_http_server').kConnectionsCheckingIntervalin the test.
Confirmed against denoland/node_test parallel/test-http-server-clear-timer.js: it emits listening twice and asserts _destroyed on the prior interval and on the saved interval after server.close(). The wiring in this PR satisfies both halves.
CI rerunning, 0 failures so far.
Enables tests/node_compat/runner/suite/test/parallel/test-http-server-clear-timer.js Co-authored-by: Divy Srivastava <[email protected]>
Reviewer flagged that switching to setInterval triggered the test sanitizer (interval started in test but never completed). Revert to core.createSystemInterval / core.cancelTimer and instead wrap the system-interval id in a small ConnectionsCheckingInterval handle that carries the Node-compatible _destroyed flag the test reads off server[kConnectionsCheckingInterval]. Co-authored-by: Divy Srivastava <[email protected]>
800f412 to
fd7a45c
Compare
Summary
Enables
test-http-server-clear-timerin node_compat suite.Test plan
cargo test --test node_compat -- test-http-server-clear-timer