Skip to content

Conversation

@aryamohanan
Copy link
Contributor

@aryamohanan aryamohanan commented Sep 22, 2025

Migrate test setup files from node-fetch-v2 to the native fetch API available in Node.js 18+. This change removes the dependency on node-fetch-v2 in the test code and uses the built-in fetch implementation instead.

Note:
This update replaces all usages of node-fetch-v2 in the test setup.

Background:

@aryamohanan aryamohanan self-assigned this Sep 25, 2025
@aryamohanan aryamohanan force-pushed the test-node-fetch branch 2 times, most recently from 8ae3d4d to 9b3dec7 Compare September 30, 2025 11:25
@kirrg001
Copy link
Contributor

kirrg001 commented Oct 2, 2025

https://jsw.ibm.com/browse/INSTA-15850

'request to http://127.0.0.1:65212/ failed, reason: connect ' +
'ECONNREFUSED 127.0.0.1:65212 -- console.error - should be traced'
));
runAndTrace('exit-span', true, 'fetch failed -- console.error - should be traced'));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Native fetch and node-fetch represent the same failure; they are just surfaced differently.

Native fetch:

  • Throws a TypeError: fetch failed
  • The real cause is nested under error.cause

node-fetch:

  • Throws a FetchError
  • The connection error is exposed directly

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm but where is the ECONNREFUSED information?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, its there

TypeError: fetch failed
at node:internal/deps/undici/undici:14900:13
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
[cause]: Error: connect ECONNREFUSED 127.0.0.1:65212
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1637:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 65212
}
} console.error - should be traced

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I guess there is a bug in the instrumentation?
See also https://github.com/instana/nodejs/pull/2022/files#r2675869932

@aryamohanan aryamohanan marked this pull request as ready for review January 2, 2026 09:18
@aryamohanan aryamohanan requested a review from a team as a code owner January 2, 2026 09:18
@aryamohanan aryamohanan removed the WIP label Jan 2, 2026
@abhilash-sivan
Copy link
Contributor

I believe this also needs to be removed!

@aryamohanan
Copy link
Contributor Author

aryamohanan commented Jan 7, 2026

I believe this also needs to be removed!

@abhilash-sivan IMO, this is not part of the test setup code. It is a minimal test application (metrics-test-app) that exists solely to be test the metrics collection.

The purpose of the test is to verify that when this application runs with node-fetch as a dependency, the metrics system reports it correctly. Therefore, this dependency is not related to test setup and does not need to be replaced or removed the test explicitly requires an external dependency to validate the behavior.

Copy link
Contributor

@abhilash-sivan abhilash-sivan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@kirrg001 kirrg001 left a comment

Choose a reason for hiding this comment

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

See comments 👍

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 9, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants