Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Nov 29, 2023

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.

@dyladan dyladan changed the title Add support for node 20 [next] Add support for node 20 Nov 29, 2023
Comment on lines +333 to +335
if (request.listenerCount('request') <= 0) {
response.resume();
}
Copy link
Member Author

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`;
Copy link
Member Author

@dyladan dyladan Nov 29, 2023

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.

Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Merging #4331 (00df7d4) into next (543f0b4) will decrease coverage by 0.09%.
Report is 1 commits behind head on next.
The diff coverage is 100.00%.

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     
Files Coverage Δ
...ges/opentelemetry-instrumentation-http/src/http.ts 93.95% <100.00%> (+0.03%) ⬆️

... and 19 files with indirect coverage changes

@dyladan dyladan marked this pull request as ready for review November 29, 2023 21:18
@dyladan dyladan requested a review from a team November 29, 2023 21:18
@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (request.listenerCount('request') <= 0) {
if (request.listenerCount('response') <= 0) {

Naive Q: should that eventName be response?

@dyladan
Copy link
Member Author

dyladan commented Dec 13, 2023

Replaced by #4363 and #4332

@dyladan dyladan closed this Dec 13, 2023
@dyladan dyladan deleted the node-20-next branch December 13, 2023 13:58
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.

3 participants