Skip to content

Commit

Permalink
test: Unflake some node-integration-tests (#13771)
Browse files Browse the repository at this point in the history
This fails sometimes (e.g.
https:/getsentry/sentry-javascript/actions/runs/11016486300/job/30592307032),
probably due to tiny timing issues.
  • Loading branch information
mydea authored Sep 24, 2024
1 parent 354dcee commit 9018132
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,25 @@ Sentry.init({

import * as http from 'http';

Sentry.startSpan({ name: 'test_span' }, () => {
http.get(`${process.env.SERVER_URL}/api/v0`);
http.get(`${process.env.SERVER_URL}/api/v1`);
http.get(`${process.env.SERVER_URL}/api/v2`);
http.get(`${process.env.SERVER_URL}/api/v3`);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Sentry.startSpan({ name: 'test_span' }, async () => {
await makeHttpRequest(`${process.env.SERVER_URL}/api/v0`);
await makeHttpRequest(`${process.env.SERVER_URL}/api/v1`);
await makeHttpRequest(`${process.env.SERVER_URL}/api/v2`);
await makeHttpRequest(`${process.env.SERVER_URL}/api/v3`);
});

function makeHttpRequest(url: string): Promise<void> {
return new Promise<void>(resolve => {
http
.request(url, httpRes => {
httpRes.on('data', () => {
// we don't care about data
});
httpRes.on('end', () => {
resolve();
});
})
.end();
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,25 @@ Sentry.init({

import * as http from 'http';

Sentry.startSpan({ name: 'test_span' }, () => {
http.get(`${process.env.SERVER_URL}/api/v0`);
http.get(`${process.env.SERVER_URL}/api/v1`);
http.get(`${process.env.SERVER_URL}/api/v2`);
http.get(`${process.env.SERVER_URL}/api/v3`);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Sentry.startSpan({ name: 'test_span' }, async () => {
await makeHttpRequest(`${process.env.SERVER_URL}/api/v0`);
await makeHttpRequest(`${process.env.SERVER_URL}/api/v1`);
await makeHttpRequest(`${process.env.SERVER_URL}/api/v2`);
await makeHttpRequest(`${process.env.SERVER_URL}/api/v3`);
});

function makeHttpRequest(url: string): Promise<void> {
return new Promise<void>(resolve => {
http
.request(url, httpRes => {
httpRes.on('data', () => {
// we don't care about data
});
httpRes.on('end', () => {
resolve();
});
})
.end();
});
}

0 comments on commit 9018132

Please sign in to comment.