Repository navigation
Re-enable the http.request(url) with url.headers test - #8607
Conversation
There was a problem hiding this comment.
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: thestrictEqualchecks run inside thehttp.requestresponse callback, which is a'response'event listener. If one of them throws, the error does not reachreject. The test then either hangs, becauseres.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 onetestHttpClientDefaultHeadersExistalready 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.foofalls 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.
520d011 to
1dab6a0
Compare
There was a problem hiding this comment.
✅ 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-urlandx-echo-fooheaders on the shared pong server don't change what the other tests see.x-echo-foofalls back to''when there is nofooheader.
📝 Documentation: ✅ LGTM
No documentation concerns. Removing the stale TODO comment is the right call.
Reviewed commit: 1dab6a0d
testHttpClientRequestOptions, the port of Node'stest-http-client-request-options, was commented out as an IoContext error. The real failure was "Connection refused": the test sent its request tolocalhost, but the sidecar only listens onSIDECAR_HOSTNAME. node:http already sends the headers set on the URL object, sinceurlToHttpOptionscopies 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 thefooheader back, so the test can check what Node's test checks on the server: the path is/ping?q=termandfooisBar.