Skip to content

Commit eb8d88e

Browse files
committed
fix(node): Fix for manual tests in node
Set port to 0 for servers in node manual tests so that an empty port is assigned rather then explicitly picking a port that might be taken. Also, add explicit server close statement to ensure that server is closed
1 parent 10938a7 commit eb8d88e

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

packages/node/test/manual/apm-transaction/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ app.get('/trace', async (_req, res, next) => {
105105
app.use(Tracing.finish());
106106
app.use(Sentry.Handlers.errorHandler());
107107

108-
const server = app.listen(1231, () => {
109-
http.get('http://localhost:1231/trace', res => {
108+
const server = app.listen(0, () => {
109+
const port = server.address().port;
110+
http.get(`http://localhost:${port}/trace`, res => {
110111
server.close();
111112
});
112113
});

packages/node/test/manual/express-scope-separation/start.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class DummyTransport {
1818

1919
if (!remaining) {
2020
console.error('SUCCESS: All scopes contain correct tags');
21+
server.close();
2122
process.exit(0);
2223
}
2324

@@ -83,8 +84,9 @@ app.get('/baz', req => {
8384

8485
app.use(Sentry.Handlers.errorHandler());
8586

86-
app.listen(1121);
87-
88-
http.get('http://localhost:1121/foo');
89-
http.get('http://localhost:1121/bar');
90-
http.get('http://localhost:1121/baz');
87+
const server = app.listen(0, () => {
88+
const port = server.address().port;
89+
http.get(`http://localhost:${port}/foo`);
90+
http.get(`http://localhost:${port}/bar`);
91+
http.get(`http://localhost:${port}/baz`);
92+
});

packages/node/test/manual/memory-leak/express-patient.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ app.use((err, req, res, next) => {
146146
return res.status(500).send('oh no there was an error: ' + err.message);
147147
});
148148

149-
const server = app.listen(5140, () => {
150-
process._rawDebug('patient is waiting to be poked on port 5140');
149+
const server = app.listen(0, () => {
150+
const port = server.address().port;
151+
process._rawDebug(`patient is waiting to be poked on port ${port}`);
151152
memwatch.gc();
152153
});

0 commit comments

Comments
 (0)