Skip to content

Re-enable the http.request(url) with url.headers test - #8607

Merged
littledivy merged 1 commit into
mainfrom
littledivy/2026-11-18-node-http-url-headers
Nov 18, 2026
Merged

littledivy merged 1 commit into
mainfrom
littledivy/2026-11-18-node-http-url-headers

Conversation

@littledivy

Copy link
Copy Markdown
Member

testHttpClientRequestOptions, the port of Node's test-http-client-request-options, was commented out as an IoContext error. The real failure was "Connection refused": the test sent its request to localhost, but the sidecar only listens on SIDECAR_HOSTNAME. node:http already sends the headers set on the URL object, since urlToHttpOptions copies the URL's own properties.

In this patch the test is re-enabled and sends its request to SIDECAR_HOSTNAME. The pong server echoes the request path and the foo header back, so the test can check what Node's test checks on the server: the path is /ping?q=term and foo is Bar.

@littledivy
littledivy requested review from a team as code owners November 18, 2026 13:27

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of 1dab6a0d.

This review, of 520d0116

💬 Approved with comments — Test-only change that re-enables the test correctly. The one INFO note is about how assertion failures inside the response callback get reported.

Findings: 1 info (1 is an inline comment on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: 💬 1 info

The re-enabled test and the pong server's echo headers look correct. Assertions inside the response callback may not fail the test cleanly.

Recommendation: 💬 Optional Nits

  • [INFO] Assertions in the response callback are not routed to reject, so a failure may hang the test or show up as an uncaught exception instead of a clear assertion failure. (src/workerd/api/node/tests/http-client-nodejs-test.js:37)
View full review
  • src/workerd/api/node/tests/http-client-nodejs-test.js:36-40: the strictEqual checks run inside the http.request response callback, which is a 'response' event listener. If one of them throws, the error does not reach reject. The test then either hangs, because res.resume() is never reached, or fails with a confusing uncaught-exception error. It does not fail with a clear assertion message. A simpler, more robust shape is the one testHttpClientDefaultHeadersExist already uses: const [res] = await once(clientReq, 'response');, then run the assertions after the await.
  • src/workerd/api/node/tests/http-client-nodejs-server.js: the echo headers do not affect the other tests that share the pong server. foo falls back to '' when the header is absent.

✅ All other checks passed

📝 Documentation: ✅ LGTM

No documentation concerns. Removing the stale TODO comment is appropriate.


Reviewed commit: 520d0116

testHttpClientRequestOptions, the port of Node's test-http-client-request-options, was commented out as an IoContext error. The real failure was "Connection refused": the test sent its request to localhost, but the sidecar only listens on SIDECAR_HOSTNAME. node:http already sends the headers set on the URL object, since urlToHttpOptions copies the URL's own properties.

In this patch the test is re-enabled and sends its request to SIDECAR_HOSTNAME. The pong server echoes the request path and the foo header back, so the test can check what Node's test checks on the server: the path is /ping?q=term and foo is Bar.
@littledivy
littledivy force-pushed the littledivy/2026-11-18-node-http-url-headers branch from 520d011 to 1dab6a0 Compare November 18, 2026 13:32

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — This test-only change re-enables the test correctly, and the note from the last review about assertions inside the response callback is fixed.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

  • Earlier note fixed: the test now uses const [res] = await once(clientReq, 'response') and asserts after the await (http-client-nodejs-test.js:38-40), so a failed assertion rejects the test instead of hanging it.
  • Request target: the request now goes to SIDECAR_HOSTNAME, the host the sidecar server listens on.
  • Other tests unaffected: the new x-echo-url and x-echo-foo headers on the shared pong server don't change what the other tests see. x-echo-foo falls back to '' when there is no foo header.

📝 Documentation: ✅ LGTM

No documentation concerns. Removing the stale TODO comment is the right call.


Reviewed commit: 1dab6a0d

@littledivy
littledivy merged commit a914ada into main Nov 18, 2026
36 of 38 checks passed
@littledivy
littledivy deleted the littledivy/2026-11-18-node-http-url-headers branch November 18, 2026 15:23
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.

2 participants