-
Notifications
You must be signed in to change notification settings - Fork 832
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
[next] Add support for node 20 #4331
Conversation
if (request.listenerCount('request') <= 0) { | ||
response.resume(); | ||
} |
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.
If we are the only listener, we have to make sure to read the response data. Otherwise the connection is never closed.
@@ -22,7 +22,7 @@ export async function sendRequestTwice( | |||
port: number | |||
): Promise<Buffer> { | |||
return new Promise((resolve, reject) => { | |||
const request = 'GET /raw HTTP/1.1\n\n'; | |||
const request = `GET /raw HTTP/1.1\r\nHost: ${host}:${port}\r\n\r\n`; |
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.
According to spec Host
header is required. In node 20 this started to be enforced by default. Spec also requires \r\n
not \n
.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## next #4331 +/- ##
==========================================
- Coverage 92.24% 92.16% -0.09%
==========================================
Files 332 316 -16
Lines 9437 8536 -901
Branches 1999 1803 -196
==========================================
- Hits 8705 7867 -838
+ Misses 732 669 -63
|
@@ -330,6 +330,9 @@ export class HttpInstrumentation extends InstrumentationBase<Http> { | |||
'response', | |||
(response: http.IncomingMessage & { aborted?: boolean }) => { | |||
this._diag.debug('outgoingRequest on response()'); | |||
if (request.listenerCount('request') <= 0) { |
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.
if (request.listenerCount('request') <= 0) { | |
if (request.listenerCount('response') <= 0) { |
Naive Q: should that eventName be response
?
One of these changes fixes a memory leak. It is implemented for
1.x
in #4332. The other is simply an HTTP specification fix which only affects testing.