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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
node_version:
- 18
- 20
runs-on: self-hosted
timeout-minutes: 10
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- uses: actions/checkout@v4

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
node_version:
- "18"
# - "20" # disabled until http instrumentation can be fixed
- "20"
runs-on: ubuntu-latest
env:
NPM_CONFIG_UNSAFE_PERM: true
Expand All @@ -40,7 +40,7 @@ jobs:
npm run test
- name: Report Coverage
run: npm run codecov
if: ${{ matrix.node_version == '18' }}
if: ${{ matrix.node_version == '20' }}
node-windows-tests:
runs-on: windows-latest
env:
Expand All @@ -51,7 +51,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '18'
node-version: 20

- run: npm install -g npm@latest

Expand All @@ -77,7 +77,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Bootstrap
run: npm ci
Expand All @@ -98,7 +98,7 @@ jobs:
uses: actions/[email protected]
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Bootstrap
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/w3c-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Install and Bootstrap 🔧
run: npm ci
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?

response.resume();
}
Comment on lines +333 to +335
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.

const responseAttributes =
utils.getOutgoingRequestAttributesOnResponse(response);
span.setAttributes(responseAttributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

const socket = net.createConnection({ host, port }, () => {
socket.write(`${request}${request}`, err => {
if (err) reject(err);
Expand Down