-
Notifications
You must be signed in to change notification settings - Fork 6k
fix(ext/node): implement dns Resolver cancel() and timeout support #33580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ae26eaf
4992b21
022cbab
8ba1688
906b839
6a099a2
e4a548f
6883e55
669f583
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -780,6 +780,10 @@ | |
| // TODO(bartlomieju): this test was disabled during work on `node:inspector`, it never worked | ||
| // "parallel/test-disable-sigusr1.js": {}, | ||
| "parallel/test-disable-sigusr1.js": {}, | ||
| "parallel/test-dns-cancel-reverse-lookup.js": {}, | ||
| "parallel/test-dns-channel-cancel.js": {}, | ||
| "parallel/test-dns-channel-cancel-promise.js": {}, | ||
| "parallel/test-dns-channel-timeout.js": {}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing |
||
| "parallel/test-dns-default-order-ipv4.js": {}, | ||
| "parallel/test-dns-default-order-ipv6.js": {}, | ||
| "parallel/test-dns-default-order-verbatim.js": {}, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cancel()only walks#pendingQueriesand firesreq.oncomplete("ECANCELLED", [])synchronously — it doesn't actually abort the underlyingop_dns_resolve. For thetimeoutpath the cancel handle does abort the op, but here (no timeout set) the op stays alive until hickory's own timeout (~5s default ×attempts) fires.Failure pattern in CI on linux-aarch64 (https://github.com/denoland/deno/actions/runs/25011070179/job/73247390033):
The user-facing callback fires
ECANCELLEDimmediately, but the orphanedop_dns_resolvekeeps the test's event loop alive until hickory times out. The 10002ms pretty clearly aligns with hickory's default 5s × 2 attempts.Fix: extend the cancel-handle pattern to all queries, not just the timeout path. Roughly — give every
#querycall a cancelRid up front, store it on thereq(or in a parallel map), and havecancel()core.tryCloseeach one in addition to (or instead of) firing oncomplete. Something like:The op should then return
Deno.errors.Interruptedand the existing catch in#querywill short-circuit, so the test's event loop can drain.(There may be additional issues if
req.oncomplete("ECANCELLED", [])doesn't get mapped throughdnsExceptionto set.code/.syscall/.hostnamecorrectly in the test's assertion — worth verifying that string code passes through the existing dispatch, sincednsExceptionis typically built around integer error codes.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already addressed in the current code --
cancel()now walks#cancelRidsand callscore.tryClose(rid)on each one (lines 748-751), in addition to firingoncomplete("ECANCELLED", [])on pending queries. Every#querycall creates a cancel handle viacore.createCancelHandle()(line 305), stores it in#cancelRids(line 306), and cleans it up on completion (lines 312, 339). So orphanedop_dns_resolvecalls are properly aborted and the event loop can drain.