Skip to content

Commit 9018132

Browse files
authored
test: Unflake some node-integration-tests (getsentry#13771)
This fails sometimes (e.g. https://github.com/getsentry/sentry-javascript/actions/runs/11016486300/job/30592307032), probably due to tiny timing issues.
1 parent 354dcee commit 9018132

File tree

2 files changed

+42
-10
lines changed
  • dev-packages/node-integration-tests/suites/tracing

2 files changed

+42
-10
lines changed

dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/scenario.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,25 @@ Sentry.init({
1212

1313
import * as http from 'http';
1414

15-
Sentry.startSpan({ name: 'test_span' }, () => {
16-
http.get(`${process.env.SERVER_URL}/api/v0`);
17-
http.get(`${process.env.SERVER_URL}/api/v1`);
18-
http.get(`${process.env.SERVER_URL}/api/v2`);
19-
http.get(`${process.env.SERVER_URL}/api/v3`);
15+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
16+
Sentry.startSpan({ name: 'test_span' }, async () => {
17+
await makeHttpRequest(`${process.env.SERVER_URL}/api/v0`);
18+
await makeHttpRequest(`${process.env.SERVER_URL}/api/v1`);
19+
await makeHttpRequest(`${process.env.SERVER_URL}/api/v2`);
20+
await makeHttpRequest(`${process.env.SERVER_URL}/api/v3`);
2021
});
22+
23+
function makeHttpRequest(url: string): Promise<void> {
24+
return new Promise<void>(resolve => {
25+
http
26+
.request(url, httpRes => {
27+
httpRes.on('data', () => {
28+
// we don't care about data
29+
});
30+
httpRes.on('end', () => {
31+
resolve();
32+
});
33+
})
34+
.end();
35+
});
36+
}

dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/scenario.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,25 @@ Sentry.init({
1212

1313
import * as http from 'http';
1414

15-
Sentry.startSpan({ name: 'test_span' }, () => {
16-
http.get(`${process.env.SERVER_URL}/api/v0`);
17-
http.get(`${process.env.SERVER_URL}/api/v1`);
18-
http.get(`${process.env.SERVER_URL}/api/v2`);
19-
http.get(`${process.env.SERVER_URL}/api/v3`);
15+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
16+
Sentry.startSpan({ name: 'test_span' }, async () => {
17+
await makeHttpRequest(`${process.env.SERVER_URL}/api/v0`);
18+
await makeHttpRequest(`${process.env.SERVER_URL}/api/v1`);
19+
await makeHttpRequest(`${process.env.SERVER_URL}/api/v2`);
20+
await makeHttpRequest(`${process.env.SERVER_URL}/api/v3`);
2021
});
22+
23+
function makeHttpRequest(url: string): Promise<void> {
24+
return new Promise<void>(resolve => {
25+
http
26+
.request(url, httpRes => {
27+
httpRes.on('data', () => {
28+
// we don't care about data
29+
});
30+
httpRes.on('end', () => {
31+
resolve();
32+
});
33+
})
34+
.end();
35+
});
36+
}

0 commit comments

Comments
 (0)