Skip to content

Commit 6fa1b8d

Browse files
committed
ensure everything is properly closed
1 parent a49fdad commit 6fa1b8d

File tree

21 files changed

+64
-301
lines changed

21 files changed

+64
-301
lines changed

dev-packages/node-integration-tests/README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ requests, and assertions. Test server, interceptors and assertions are all run o
3838

3939
`utils/` contains helpers and Sentry-specific assertions that can be used in (`test.ts`).
4040

41-
`TestEnv` class contains methods to create and execute requests on a test server instance. `TestEnv.init()` which starts
42-
a test server and returns a `TestEnv` instance must be called by each test. The test server is automatically shut down
43-
after each test, if a data collection helper method such as `getEnvelopeRequest` and `getAPIResponse` is used. Tests
44-
that do not use those helper methods will need to end the server manually.
45-
46-
`TestEnv` instance has two public properties: `url` and `server`. The `url` property is the base URL for the server. The
47-
`http.Server` instance is used to finish the server eventually.
48-
4941
Nock interceptors are internally used to capture envelope requests by `getEnvelopeRequest` and
5042
`getMultipleEnvelopeRequest` helpers. After capturing required requests, the interceptors are removed. Nock can manually
5143
be used inside the test cases to intercept requests but should be removed before the test ends, as not to cause

dev-packages/node-integration-tests/suites/tracing/connect/scenario.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Sentry.init({
1313
const connect = require('connect');
1414
const http = require('http');
1515

16-
const init = async () => {
16+
const run = async () => {
1717
const app = connect();
1818

1919
app.use('/', function (req, res, next) {
@@ -34,4 +34,4 @@ const init = async () => {
3434
sendPortToRunner(port);
3535
};
3636

37-
init();
37+
run();

dev-packages/node-integration-tests/suites/tracing/hapi/scenario.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Boom = require('@hapi/boom');
1313

1414
const port = 5999;
1515

16-
const init = async () => {
16+
const run = async () => {
1717
const server = Hapi.server({
1818
host: 'localhost',
1919
port,
@@ -65,4 +65,4 @@ const init = async () => {
6565
sendPortToRunner(port);
6666
};
6767

68-
init();
68+
run();

dev-packages/node-integration-tests/suites/tracing/nestjs-errors-no-express/scenario.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class AppController {
4747
})
4848
class AppModule {}
4949

50-
async function init(): Promise<void> {
50+
async function run(): Promise<void> {
5151
const app = await NestFactory.create(AppModule);
5252
const { httpAdapter } = app.get(HttpAdapterHost);
5353
Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter));
@@ -56,4 +56,4 @@ async function init(): Promise<void> {
5656
}
5757

5858
// eslint-disable-next-line @typescript-eslint/no-floating-promises
59-
init();
59+
run();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class AppController {
4545
})
4646
class AppModule {}
4747

48-
async function init(): Promise<void> {
48+
async function run(): Promise<void> {
4949
const app = await NestFactory.create(AppModule);
5050
const { httpAdapter } = app.get(HttpAdapterHost);
5151
Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter));
@@ -54,4 +54,4 @@ async function init(): Promise<void> {
5454
}
5555

5656
// eslint-disable-next-line @typescript-eslint/no-floating-promises
57-
init();
57+
run();

dev-packages/node-integration-tests/suites/tracing/nestjs-no-express/scenario.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class AppController {
4747
})
4848
class AppModule {}
4949

50-
async function init(): Promise<void> {
50+
async function run(): Promise<void> {
5151
const app = await NestFactory.create(AppModule);
5252
const { httpAdapter } = app.get(HttpAdapterHost);
5353
Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(httpAdapter));
@@ -56,4 +56,4 @@ async function init(): Promise<void> {
5656
}
5757

5858
// eslint-disable-next-line @typescript-eslint/no-floating-promises
59-
init();
59+
run();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ class AppController {
4545
})
4646
class AppModule {}
4747

48-
async function init(): Promise<void> {
48+
async function run(): Promise<void> {
4949
const app = await NestFactory.create(AppModule);
5050
await app.listen(port);
5151
sendPortToRunner(port);
5252
}
5353

5454
// eslint-disable-next-line @typescript-eslint/no-floating-promises
55-
init();
55+
run();

dev-packages/node-integration-tests/suites/tracing/requests/fetch-breadcrumbs/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ conditionalTest({ min: 18 })('outgoing fetch', () => {
66
test('outgoing fetch requests create breadcrumbs', done => {
77
createTestServer(done)
88
.start()
9-
.then(SERVER_URL => {
9+
.then(([SERVER_URL, closeTestServer]) => {
1010
createRunner(__dirname, 'scenario.ts')
1111
.withEnv({ SERVER_URL })
1212
.ensureNoErrorOutput()
@@ -72,7 +72,7 @@ conditionalTest({ min: 18 })('outgoing fetch', () => {
7272
},
7373
},
7474
})
75-
.start(done);
75+
.start(closeTestServer);
7676
});
7777
});
7878
});

dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ conditionalTest({ min: 18 })('outgoing fetch', () => {
2626
expect(headers['sentry-trace']).toBeUndefined();
2727
})
2828
.start()
29-
.then(SERVER_URL => {
29+
.then(([SERVER_URL, closeTestServer]) => {
3030
createRunner(__dirname, 'scenario.ts')
3131
.withEnv({ SERVER_URL })
3232
.ensureNoErrorOutput()
@@ -42,7 +42,7 @@ conditionalTest({ min: 18 })('outgoing fetch', () => {
4242
},
4343
},
4444
})
45-
.start(done);
45+
.start(closeTestServer);
4646
});
4747
});
4848
});

dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ conditionalTest({ min: 18 })('outgoing fetch', () => {
2626
expect(headers['sentry-trace']).toBeUndefined();
2727
})
2828
.start()
29-
.then(SERVER_URL => {
29+
.then(([SERVER_URL, closeTestServer]) => {
3030
createRunner(__dirname, 'scenario.ts')
3131
.withEnv({ SERVER_URL })
3232
.expect({
@@ -41,7 +41,7 @@ conditionalTest({ min: 18 })('outgoing fetch', () => {
4141
},
4242
},
4343
})
44-
.start(done);
44+
.start(closeTestServer);
4545
});
4646
});
4747
});

0 commit comments

Comments
 (0)