-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DI] Ensure the tracer doesn't block instrumented app from exiting (#…
…4993) The `MessagePort` objects should be unref'ed (has to be after any message handler has been attached). Otherwise their handle will keep the instrumented app running. Technically there's no need to unref `port1`, but let's just unref everything show the intent.
- Loading branch information
Showing
4 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict' | ||
|
||
require('dd-trace/init') | ||
const http = require('http') | ||
|
||
const server = http.createServer((req, res) => { | ||
res.end('hello world') // BREAKPOINT | ||
setImmediate(() => { | ||
server.close() | ||
}) | ||
}) | ||
|
||
server.listen(process.env.APP_PORT, () => { | ||
process.send({ port: process.env.APP_PORT }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict' | ||
|
||
const { assert } = require('chai') | ||
const { setup } = require('./utils') | ||
|
||
describe('Dynamic Instrumentation', function () { | ||
const t = setup() | ||
|
||
it('should not hinder the program from exiting', function (done) { | ||
// Expect the instrumented app to exit after receiving an HTTP request. Will time out otherwise. | ||
t.proc.on('exit', (code) => { | ||
assert.strictEqual(code, 0) | ||
done() | ||
}) | ||
t.axios.get('/') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters