diff --git a/metapackages/auto-instrumentations-node/test/register.test.ts b/metapackages/auto-instrumentations-node/test/register.test.ts index 47917c854b..2f952541db 100644 --- a/metapackages/auto-instrumentations-node/test/register.test.ts +++ b/metapackages/auto-instrumentations-node/test/register.test.ts @@ -90,7 +90,7 @@ describe('Register', function () { it('shuts down the NodeSDK when SIGTERM is received', async () => { const runPromise = runWithRegister('./test-app/app-server.js'); const { child } = runPromise; - await waitForString(child.stdout!, 'Finished request'); + await waitForString(child.stdout!, 'Finshed request'); child.kill('SIGTERM'); const { stdout } = await runPromise; diff --git a/metapackages/auto-instrumentations-node/test/test-app/app-server.js b/metapackages/auto-instrumentations-node/test/test-app/app-server.js index 61e12b089e..489b4dfb7a 100644 --- a/metapackages/auto-instrumentations-node/test/test-app/app-server.js +++ b/metapackages/auto-instrumentations-node/test/test-app/app-server.js @@ -17,34 +17,22 @@ //Used in register.test.ts to mimic a JS app that stays alive like a server. const http = require('http'); -// Create a local server that responds immediately -const server = http.createServer((req, res) => { - res.end('ok'); -}); - -server.listen(0, () => { - const port = server.address().port; - const req = http.request({ - hostname: 'localhost', - port: port, - path: '/', - method: 'GET', - }); +const options = { + hostname: 'example.com', + port: 80, + path: '/', + method: 'GET', +}; - req.end(); - req.on('response', res => { - res.on('end', () => { - console.log('Finished request'); - }); - res.resume(); - }); +const req = http.request(options); +req.end(); +req.on('close', () => { + console.log('Finshed request'); }); // Make sure there is work on the event loop const handle = setInterval(() => {}, 1); - // Gracefully shut down process.on('SIGTERM', () => { clearInterval(handle); - server.close(); });