File tree Expand file tree Collapse file tree 4 files changed +42
-6
lines changed
integration-tests/debugger
packages/dd-trace/src/debugger Expand file tree Collapse file tree 4 files changed +42
-6
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ require ( 'dd-trace/init' )
4
+ const http = require ( 'http' )
5
+
6
+ const server = http . createServer ( ( req , res ) => {
7
+ res . end ( 'hello world' ) // BREAKPOINT
8
+ setImmediate ( ( ) => {
9
+ server . close ( )
10
+ } )
11
+ } )
12
+
13
+ server . listen ( process . env . APP_PORT , ( ) => {
14
+ process . send ( { port : process . env . APP_PORT } )
15
+ } )
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const { assert } = require ( 'chai' )
4
+ const { setup } = require ( './utils' )
5
+
6
+ describe ( 'Dynamic Instrumentation' , function ( ) {
7
+ const t = setup ( )
8
+
9
+ it ( 'should not hinder the program from exiting' , function ( done ) {
10
+ // Expect the instrumented app to exit after receiving an HTTP request. Will time out otherwise.
11
+ t . proc . on ( 'exit' , ( code ) => {
12
+ assert . strictEqual ( code , 0 )
13
+ done ( )
14
+ } )
15
+ t . axios . get ( '/' )
16
+ } )
17
+ } )
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ module.exports = {
18
18
}
19
19
20
20
function setup ( ) {
21
- let sandbox , cwd , appPort , proc
21
+ let sandbox , cwd , appPort
22
22
const breakpoint = getBreakpointInfo ( 1 ) // `1` to disregard the `setup` function
23
23
const t = {
24
24
breakpoint,
@@ -68,7 +68,7 @@ function setup () {
68
68
}
69
69
70
70
before ( async function ( ) {
71
- sandbox = await createSandbox ( [ 'fastify' ] )
71
+ sandbox = await createSandbox ( [ 'fastify' ] ) // TODO: Make this dynamic
72
72
cwd = sandbox . folder
73
73
t . appFile = join ( cwd , ...breakpoint . file . split ( '/' ) )
74
74
} )
@@ -81,7 +81,7 @@ function setup () {
81
81
t . rcConfig = generateRemoteConfig ( breakpoint )
82
82
appPort = await getPort ( )
83
83
t . agent = await new FakeAgent ( ) . start ( )
84
- proc = await spawnProc ( t . appFile , {
84
+ t . proc = await spawnProc ( t . appFile , {
85
85
cwd,
86
86
env : {
87
87
APP_PORT : appPort ,
@@ -97,7 +97,7 @@ function setup () {
97
97
} )
98
98
99
99
afterEach ( async function ( ) {
100
- proc . kill ( )
100
+ t . proc . kill ( )
101
101
await t . agent . stop ( )
102
102
} )
103
103
Original file line number Diff line number Diff line change @@ -57,8 +57,6 @@ function start (config, rc) {
57
57
}
58
58
)
59
59
60
- worker . unref ( )
61
-
62
60
worker . on ( 'online' , ( ) => {
63
61
log . debug ( `Dynamic Instrumentation worker thread started successfully (thread id: ${ worker . threadId } )` )
64
62
} )
@@ -80,6 +78,12 @@ function start (config, rc) {
80
78
rcAckCallbacks . delete ( ackId )
81
79
}
82
80
} )
81
+
82
+ worker . unref ( )
83
+ rcChannel . port1 . unref ( )
84
+ rcChannel . port2 . unref ( )
85
+ configChannel . port1 . unref ( )
86
+ configChannel . port2 . unref ( )
83
87
}
84
88
85
89
function configure ( config ) {
You can’t perform that action at this time.
0 commit comments