-
Notifications
You must be signed in to change notification settings - Fork 39
test: replaced node-fetch with native fetch in test setup #2022
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
base: main
Are you sure you want to change the base?
Conversation
f6e2ca8 to
9a12921
Compare
8ae3d4d to
9b3dec7
Compare
9b3dec7 to
1c4034b
Compare
a2d3f22 to
72fbfc4
Compare
| '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')); |
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.
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
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.
Hm but where is the ECONNREFUSED information?
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.
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
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.
Then I guess there is a bug in the instrumentation?
See also https://github.com/instana/nodejs/pull/2022/files#r2675869932
b17ea69 to
f1ba9ae
Compare
|
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. |
abhilash-sivan
left a comment
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.
LGTM
kirrg001
left a comment
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.
See comments 👍
packages/collector/test/tracing/protocols/http/client/sdkApp1.js
Outdated
Show resolved
Hide resolved
7c3de3c to
a8c227a
Compare
|



Migrate test setup files from
node-fetch-v2to the nativefetchAPI available in Node.js 18+. This change removes the dependency onnode-fetch-v2in the test code and uses the built-infetchimplementation instead.Note:
This update replaces all usages of
node-fetch-v2in the test setup.Background:
node-fetch-v2: https://github.com/instana/nodejs/pull/1160/files