Skip to content

Commit d076231

Browse files
committed
revert LocalVariables changes
1 parent 8594b29 commit d076231

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

packages/node/src/integrations/localvariables.ts

+10-25
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,26 @@ export interface DebugSession {
2424
* https://nodejs.org/docs/latest-v14.x/api/inspector.html
2525
*/
2626
class AsyncSession implements DebugSession {
27-
private _session: Session | undefined = undefined;
28-
29-
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
30-
private readonly _inspectorModulePromise: Promise<typeof import('inspector')>;
27+
private readonly _session: Session;
3128

3229
/** Throws is inspector API is not available */
3330
public constructor() {
3431
// Node can be build without inspector support so this can throw
35-
// @ts-ignore eslint-disable-next-line @typescript-eslint/no-var-requires
36-
this._inspectorModulePromise = import('inspector');
32+
// eslint-disable-next-line @typescript-eslint/no-var-requires
33+
const { Session } = require('inspector');
34+
this._session = new Session();
3735
}
3836

3937
/** @inheritdoc */
4038
public configureAndConnect(
4139
onPause: (message: InspectorNotification<Debugger.PausedEventDataType>) => void,
4240
captureAll: boolean,
4341
): void {
44-
this._inspectorModulePromise
45-
.then(inspectorModule => {
46-
this._session = new inspectorModule.Session();
47-
this._session.connect();
48-
this._session.on('Debugger.paused', onPause);
49-
this._session.post('Debugger.enable');
50-
// We only want to pause on uncaught exceptions
51-
this._session.post('Debugger.setPauseOnExceptions', { state: captureAll ? 'all' : 'uncaught' });
52-
})
53-
.catch(_ => {
54-
/* ignoring, `inspector` isn't always available */
55-
});
42+
this._session.connect();
43+
this._session.on('Debugger.paused', onPause);
44+
this._session.post('Debugger.enable');
45+
// We only want to pause on uncaught exceptions
46+
this._session.post('Debugger.setPauseOnExceptions', { state: captureAll ? 'all' : 'uncaught' });
5647
}
5748

5849
/** @inheritdoc */
@@ -78,12 +69,6 @@ class AsyncSession implements DebugSession {
7869
*/
7970
private _getProperties(objectId: string): Promise<Runtime.PropertyDescriptor[]> {
8071
return new Promise((resolve, reject) => {
81-
if (!this._session) {
82-
// eslint-disable-next-line no-console
83-
console.error('Session is not available');
84-
reject(new Error('Session is not available'));
85-
return;
86-
}
8772
this._session.post(
8873
'Runtime.getProperties',
8974
{
@@ -207,7 +192,7 @@ export class LocalVariables implements Integration {
207192
public constructor(
208193
private readonly _options: Options = {},
209194
private readonly _session: DebugSession | undefined = tryNewAsyncSession(),
210-
) {}
195+
) { }
211196

212197
/**
213198
* @inheritDoc

0 commit comments

Comments
 (0)