Skip to content

fix(ext/node): use node:timers for http server connection checks, expo#33483

Merged
bartlomieju merged 2 commits into
denoland:mainfrom
divybot:claude/test-http-server-clear-timer
Apr 26, 2026
Merged

fix(ext/node): use node:timers for http server connection checks, expo#33483
bartlomieju merged 2 commits into
denoland:mainfrom
divybot:claude/test-http-server-clear-timer

Conversation

@divybot

@divybot divybot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Enables test-http-server-clear-timer in node_compat suite.

Test plan

  • cargo test --test node_compat -- test-http-server-clear-timer

Comment thread ext/node/polyfills/_http_server.js Outdated

const interval = this.connectionsCheckingInterval || 30_000;
this[kConnectionsCheckingInterval] = core.createSystemInterval(
this[kConnectionsCheckingInterval] = setInterval(

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.

This will cause sanitizer issues in tests. The previous code was correct

@fibibot fibibot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 when handle._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 zeroed server[kConnectionsCheckingInterval] after cancelling; the new code leaves the (now-destroyed) handle in place because the upstream test reads server[kConnectionsCheckingInterval]._destroyed after close.
  • kConnectionsCheckingInterval is now exported from _http_server, matching require('_http_server').kConnectionsCheckingInterval in 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.

divybot and others added 2 commits April 26, 2026 08:07
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]>
@divybot
divybot force-pushed the claude/test-http-server-clear-timer branch from 800f412 to fd7a45c Compare April 26, 2026 02:37
@bartlomieju
bartlomieju merged commit dd5968d into denoland:main Apr 26, 2026
112 checks passed
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.

4 participants