Skip to content

Commit e4c1246

Browse files
committed
Linting and dynamicImport
1 parent 1cebb33 commit e4c1246

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/node/src/integrations/localvariables/localvariables-async.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Session } from 'node:inspector/promises';
2-
import type { Event, EventProcessor, Exception, Hub, Integration, StackFrame, StackParser } from '@sentry/types';
2+
import type { Event, EventProcessor, Exception, Hub, Integration, StackParser } from '@sentry/types';
33
import { LRUMap, logger } from '@sentry/utils';
44
import type { Debugger, InspectorNotification, Runtime } from 'inspector';
55
import type { NodeClient } from '../../client';
@@ -8,6 +8,13 @@ import type { NodeClientOptions } from '../../types';
88
import type { FrameVariables, Options, PausedExceptionEvent, RateLimitIncrement, Variables } from './common';
99
import { createRateLimiter, functionNamesMatch, hashFrames, hashFromStack } from './common';
1010

11+
/**
12+
* When targeting older versions of node, webpack will throw an error if we try to import libraries that are not available
13+
*/
14+
function dynamicImport<T>(module: string): Promise<T> {
15+
return import(module);
16+
}
17+
1118
async function unrollArray(session: Session, objectId: string, name: string, vars: Variables): Promise<void> {
1219
const properties: Runtime.GetPropertiesReturnType = await session.post('Runtime.getProperties', {
1320
objectId,
@@ -95,7 +102,7 @@ export class LocalVariablesAsync implements Integration {
95102
return;
96103
}
97104

98-
import('node:inspector/promises')
105+
dynamicImport<{ Session: typeof Session }>('node:inspector/promises')
99106
.then(({ Session }) => this._startDebugger(new Session(), clientOptions))
100107
.catch(e => logger.error('Failed to load inspector API', e));
101108
}

packages/node/src/integrations/localvariables/localvariables-sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable max-lines */
2-
import type { Event, EventProcessor, Exception, Hub, Integration, StackFrame, StackParser } from '@sentry/types';
2+
import type { Event, EventProcessor, Exception, Hub, Integration, StackParser } from '@sentry/types';
33
import { LRUMap, logger } from '@sentry/utils';
44
import type { Debugger, InspectorNotification, Runtime, Session } from 'inspector';
55
import type { NodeClient } from '../../client';

0 commit comments

Comments
 (0)