feat: populate dnslookup timing with actual DNS resolution time#743
Draft
feat: populate dnslookup timing with actual DNS resolution time#743
Conversation
…ockets Captures DNS lookup time via Socket.prototype.emit monkey-patch for the 'lookup' event. When the first request is sent on a socket, the DNS lookup time is calculated relative to the request start time and stored in the timing object. Closes #577 Agent-Logs-Url: https://github.com/node-modules/urllib/sessions/efde376e-b12f-42f6-9490-2ce39519fe7c Co-authored-by: fengmk2 <156269+fengmk2@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix timing differentiation for DNS query
feat: populate dnslookup timing with actual DNS resolution time
Apr 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
dnslookupfield in theTimingobject was defined and initialized to0but never populated, making it impossible to distinguish DNS resolution time from overall connection time.Changes
src/symbols.ts: AddkSocketDnsLookupTimesymbol for storing DNS resolution timestamp on socketssrc/diagnosticsChannel.ts: Capture DNS lookup completion time viaSocket.prototype.emithook on the'lookup'event (same pattern as the existingSocket.prototype.destroyhook). Computednslookuptiming relative to request start in theundici:client:sendHeadershandler for first-request-on-sockettest/options.timing.test.ts: Assertdnslookup > 0anddnslookup <= connectedon first request; assertdnslookup === 0on reused socketResult
{ "queuing": 2.781, "dnslookup": 9.038, "connected": 12.655, "requestHeadersSent": 13.389, "requestSent": 13.571, "waiting": 24.036, "contentDownload": 25.092 }Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
http://registry.npmjs.org:80/urllib/latest/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --experimental-import-meta-resolve --require /home/REDACTED/work/urllib/urllib/node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.15_@arethetypeswrong+core@0.18.2_@types+node@22.19.15__7c6ae394869a5d43fd0cf7dc1d33dc1c/node_modules/@voidzero-dev/vite-plus-test/suppress-warnings.cjs --conditions node --conditions development /home/REDACTED/work/urllib/urllib/node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.15_@arethetypeswrong+core@0.18.2_@types+node@22.19.15__7c6ae394869a5d43fd0cf7dc1d33dc1c/node_modules/@voidzero-dev/vite-plus-test/dist/workers/forks.js(http block)/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --experimental-import-meta-resolve --require /home/REDACTED/work/urllib/urllib/node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.15_@arethetypeswrong+core@0.18.2_@types+node@22.19.15__7c6ae394869a5d43fd0cf7dc1d33dc1c/node_modules/@voidzero-dev/vite-plus-test/suppress-warnings.cjs --conditions node --conditions development /home/REDACTED/work/urllib/urllib/node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.15_@arethetypeswrong+core@0.18.2_@types+node@22.19.15__7c6ae394869a5d43fd0cf7dc1d33dc1c/node_modules/@voidzero-dev/vite-plus-test/dist/workers/forks.js k 3899 on REDACTED-w(http block)registry.npmmirror.com/opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --experimental-import-meta-resolve --require /home/REDACTED/work/urllib/urllib/node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.15_@arethetypeswrong+core@0.18.2_@types+node@22.19.15__7c6ae394869a5d43fd0cf7dc1d33dc1c/node_modules/@voidzero-dev/vite-plus-test/suppress-warnings.cjs --conditions node --conditions development /home/REDACTED/work/urllib/urllib/node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.15_@arethetypeswrong+core@0.18.2_@types+node@22.19.15__7c6ae394869a5d43fd0cf7dc1d33dc1c/node_modules/@voidzero-dev/vite-plus-test/dist/workers/forks.js(dns block)If you need me to access, download, or install something from one of these locations, you can either: