@@ -38,38 +38,27 @@ describe('Dynamic Instrumentation', function () {
3838 'should timeout first, then disable subsequent snapshots and emit error diagnostics' ,
3939 async function ( ) {
4040 const breakpoint = t . breakpoints [ 1 ]
41+ const expectedEvaluationErrors = [ {
42+ expr : '' ,
43+ message : 'An object with 1000000 properties was detected while collecting a snapshot. This exceeds ' +
44+ `the maximum number of allowed properties of ${ LARGE_OBJECT_SKIP_THRESHOLD } . Future snapshots for ` +
45+ 'existing probes in this location will be skipped until the Node.js process is restarted'
46+ } ]
4147
4248 // Listen for the first snapshot payload (should contain notCapturedReason: "timeout")
43- const firstPayloadReceived = new Promise ( ( resolve ) => {
44- t . agent . once ( 'debugger-input' , ( { payload : [ { debugger : { snapshot : { captures } } } ] } ) => {
45- const { locals } = captures . lines [ breakpoint . line ]
46- resolve ( locals )
49+ const firstPayloadReceived = new Promise ( /** @type {() => void } */ ( resolve ) => {
50+ t . agent . once ( 'debugger-input' , ( { payload : [ { debugger : { snapshot } } ] } ) => {
51+ const { locals } = snapshot . captures . lines [ breakpoint . line ]
52+ assert . strictEqual (
53+ containsTimeBudget ( locals ) ,
54+ true ,
55+ 'expected at least one field/element to be marked with notCapturedReason: "timeout"'
56+ )
57+ assert . deepStrictEqual ( snapshot . evaluationErrors , expectedEvaluationErrors )
58+ resolve ( )
4759 } )
4860 } )
4961
50- // Prepare to assert that an ERROR diagnostics event with exception details is emitted
51- const errorDiagnosticsReceived = new Promise ( ( /** @type {(value?: unknown) => void } */ resolve , reject ) => {
52- const handler = ( { payload } ) => {
53- payload . forEach ( ( { debugger : { diagnostics } } ) => {
54- if ( diagnostics . status !== 'ERROR' ) return
55- try {
56- assert . strictEqual (
57- diagnostics . exception . message ,
58- 'An object with 1000000 properties was detected while collecting a snapshot. This exceeds the ' +
59- 'maximum number of allowed properties of 500. Future snapshots for existing probes in this ' +
60- 'location will be skipped until the Node.js process is restarted'
61- )
62- resolve ( )
63- } catch ( e ) {
64- reject ( e )
65- } finally {
66- t . agent . off ( 'debugger-diagnostics' , handler )
67- }
68- } )
69- }
70- t . agent . on ( 'debugger-diagnostics' , handler )
71- } )
72-
7362 // Install probe with snapshot capture enabled
7463 t . agent . addRemoteConfig ( breakpoint . generateRemoteConfig ( {
7564 captureSnapshot : true ,
@@ -82,18 +71,14 @@ describe('Dynamic Instrumentation', function () {
8271 result1 . data . paused >= 1_000 ,
8372 `expected thread to be paused for at least 1 second, but was paused for ~${ result1 . data . paused } ms`
8473 )
85- const locals = await firstPayloadReceived
86- assert . strictEqual (
87- containsTimeBudget ( locals ) ,
88- true ,
89- 'expected at least one field/element to be marked with notCapturedReason: "timeout"'
90- )
91- await errorDiagnosticsReceived
74+
75+ await firstPayloadReceived
9276
9377 // Prepare to assert that no snapshot is produced on a subsequent trigger
94- const noSnapshotAfterSecondTrigger = new Promise ( ( /** @type {(value?: unknown) => void } */ resolve ) => {
95- t . agent . once ( 'debugger-input' , ( { payload : [ { debugger : { snapshot : { captures } } } ] } ) => {
96- assert . strictEqual ( captures , undefined )
78+ const secondPayloadReceived = new Promise ( /** @type {() => void } */ ( resolve ) => {
79+ t . agent . once ( 'debugger-input' , ( { payload : [ { debugger : { snapshot } } ] } ) => {
80+ assert . ok ( ! Object . hasOwn ( snapshot , 'captures' ) )
81+ assert . deepStrictEqual ( snapshot . evaluationErrors , expectedEvaluationErrors )
9782 resolve ( )
9883 } )
9984 } )
@@ -105,7 +90,7 @@ describe('Dynamic Instrumentation', function () {
10590 `expected thread to be paused <=5ms, but was paused for ~${ result2 . data . paused } ms`
10691 )
10792
108- await noSnapshotAfterSecondTrigger
93+ await secondPayloadReceived
10994 }
11095 )
11196 } )
0 commit comments