1
- import type { LRUMap } from '@sentry/utils' ;
2
1
import type { Debugger , InspectorNotification } from 'inspector' ;
3
2
4
3
import { NodeClient , defaultStackParser } from '../../src' ;
5
- import { createRateLimiter } from '../../src/integrations/localvariables /common' ;
6
- import type { FrameVariables } from '../../src/integrations/localvariables /common' ;
7
- import type { DebugSession } from '../../src/integrations/localvariables/localvariables -sync' ;
8
- import { LocalVariablesSync , createCallbackList } from '../../src/integrations/localvariables/localvariables -sync' ;
4
+ import { createRateLimiter } from '../../src/integrations/local-variables /common' ;
5
+ import type { FrameVariables } from '../../src/integrations/local-variables /common' ;
6
+ import type { DebugSession } from '../../src/integrations/local-variables/local-variables -sync' ;
7
+ import { LocalVariablesSync , createCallbackList } from '../../src/integrations/local-variables/local-variables -sync' ;
9
8
import { NODE_VERSION } from '../../src/nodeVersion' ;
10
9
import { getDefaultNodeClientOptions } from '../../test/helper/node-client-options' ;
11
10
@@ -52,7 +51,8 @@ class MockDebugSession implements DebugSession {
52
51
}
53
52
54
53
interface LocalVariablesPrivate {
55
- _cachedFrames : LRUMap < string , FrameVariables [ ] > ;
54
+ _getCachedFramesCount ( ) : number ;
55
+ _getFirstCachedFrame ( ) : FrameVariables [ ] | undefined ;
56
56
}
57
57
58
58
const exceptionEvent = {
@@ -175,9 +175,9 @@ describeIf(NODE_VERSION.major >= 18)('LocalVariables', () => {
175
175
176
176
await session . runPause ( exceptionEvent ) ;
177
177
178
- expect ( ( localVariables as unknown as LocalVariablesPrivate ) . _cachedFrames . size ) . toBe ( 1 ) ;
178
+ expect ( ( localVariables as unknown as LocalVariablesPrivate ) . _getCachedFramesCount ( ) ) . toBe ( 1 ) ;
179
179
180
- const frames : FrameVariables [ ] = ( localVariables as unknown as LocalVariablesPrivate ) . _cachedFrames . values ( ) [ 0 ] ;
180
+ const frames = ( localVariables as unknown as LocalVariablesPrivate ) . _getFirstCachedFrame ( ) ;
181
181
182
182
expect ( frames ) . toBeDefined ( ) ;
183
183
@@ -244,7 +244,7 @@ describeIf(NODE_VERSION.major >= 18)('LocalVariables', () => {
244
244
expect ( event ?. exception ?. values ?. [ 0 ] . stacktrace ?. frames ?. [ 3 ] ?. vars ) . toEqual ( { arr : [ 1 , 2 , 3 ] } ) ;
245
245
expect ( event ?. exception ?. values ?. [ 0 ] . stacktrace ?. frames ?. [ 4 ] ?. vars ) . toEqual ( { name : 'tim' } ) ;
246
246
247
- expect ( ( localVariables as unknown as LocalVariablesPrivate ) . _cachedFrames . size ) . toBe ( 0 ) ;
247
+ expect ( ( localVariables as unknown as LocalVariablesPrivate ) . _getCachedFramesCount ( ) ) . toBe ( 0 ) ;
248
248
} ) ;
249
249
250
250
it ( 'Only considers the first 5 frames' , async ( ) => {
@@ -261,9 +261,9 @@ describeIf(NODE_VERSION.major >= 18)('LocalVariables', () => {
261
261
262
262
await session . runPause ( exceptionEvent100Frames ) ;
263
263
264
- expect ( ( localVariables as unknown as LocalVariablesPrivate ) . _cachedFrames . size ) . toBe ( 1 ) ;
264
+ expect ( ( localVariables as unknown as LocalVariablesPrivate ) . _getCachedFramesCount ( ) ) . toBe ( 1 ) ;
265
265
266
- const frames : FrameVariables [ ] = ( localVariables as unknown as LocalVariablesPrivate ) . _cachedFrames . values ( ) [ 0 ] ;
266
+ const frames = ( localVariables as unknown as LocalVariablesPrivate ) . _getFirstCachedFrame ( ) ;
267
267
268
268
expect ( frames ) . toBeDefined ( ) ;
269
269
@@ -291,7 +291,7 @@ describeIf(NODE_VERSION.major >= 18)('LocalVariables', () => {
291
291
292
292
await session . runPause ( nonExceptionEvent ) ;
293
293
294
- expect ( ( localVariables as unknown as LocalVariablesPrivate ) . _cachedFrames . size ) . toBe ( 0 ) ;
294
+ expect ( ( localVariables as unknown as LocalVariablesPrivate ) . _getCachedFramesCount ( ) ) . toBe ( 0 ) ;
295
295
} ) ;
296
296
297
297
it ( 'Should not initialize when disabled' , async ( ) => {
@@ -309,7 +309,6 @@ describeIf(NODE_VERSION.major >= 18)('LocalVariables', () => {
309
309
const eventProcessor = eventProcessors . find ( processor => processor . id === 'LocalVariablesSync' ) ;
310
310
311
311
expect ( eventProcessor ) . toBeDefined ( ) ;
312
- expect ( localVariables [ '_shouldProcessEvent' ] ) . toBe ( false ) ;
313
312
} ) ;
314
313
315
314
it ( 'Should not initialize when inspector not loaded' , async ( ) => {
@@ -326,7 +325,6 @@ describeIf(NODE_VERSION.major >= 18)('LocalVariables', () => {
326
325
const eventProcessor = eventProcessors . find ( processor => processor . id === 'LocalVariablesSync' ) ;
327
326
328
327
expect ( eventProcessor ) . toBeDefined ( ) ;
329
- expect ( localVariables [ '_shouldProcessEvent' ] ) . toBe ( false ) ;
330
328
} ) ;
331
329
332
330
it ( 'Should cache identical uncaught exception events' , async ( ) => {
@@ -350,7 +348,7 @@ describeIf(NODE_VERSION.major >= 18)('LocalVariables', () => {
350
348
await session . runPause ( exceptionEvent ) ;
351
349
await session . runPause ( exceptionEvent ) ;
352
350
353
- expect ( ( localVariables as unknown as LocalVariablesPrivate ) . _cachedFrames . size ) . toBe ( 1 ) ;
351
+ expect ( ( localVariables as unknown as LocalVariablesPrivate ) . _getCachedFramesCount ( ) ) . toBe ( 1 ) ;
354
352
} ) ;
355
353
356
354
describe ( 'createCallbackList' , ( ) => {
0 commit comments