diff --git a/src/chrome/chromeDebugAdapter.ts b/src/chrome/chromeDebugAdapter.ts index 66b51bc24..c904a1541 100644 --- a/src/chrome/chromeDebugAdapter.ts +++ b/src/chrome/chromeDebugAdapter.ts @@ -2140,9 +2140,8 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter { } else { return this.remoteObjectToVariable(propDesc.name, response.result, parentEvaluateName); } - }, - error => { - logger.error('Error evaluating getter - ' + error.toString()); + }).catch(error => { + logger.error(`Error evaluating getter for '${propDesc.name}' - ${error.toString()}`); return { name: propDesc.name, value: error.toString(), variablesReference: 0 }; }); } else if (propDesc.set) { @@ -2541,19 +2540,19 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter { error => Promise.reject(errors.errorFromEvaluate(error.message))); } - public remoteObjectToVariable(name: string, object: Crdp.Runtime.RemoteObject, parentEvaluateName?: string, stringify = true, context: VariableContext = 'variables'): Promise { + public async remoteObjectToVariable(name: string, object: Crdp.Runtime.RemoteObject, parentEvaluateName?: string, stringify = true, context: VariableContext = 'variables'): Promise { name = name || '""'; if (object) { if (object.type === 'object') { return this.createObjectVariable(name, object, parentEvaluateName, context); } else if (object.type === 'function') { - return Promise.resolve(this.createFunctionVariable(name, object, context, parentEvaluateName)); + return this.createFunctionVariable(name, object, context, parentEvaluateName); } else { - return Promise.resolve(this.createPrimitiveVariable(name, object, parentEvaluateName, stringify)); + return this.createPrimitiveVariable(name, object, parentEvaluateName, stringify); } } else { - return Promise.resolve(this.createPrimitiveVariableWithValue(name, '', parentEvaluateName)); + return this.createPrimitiveVariableWithValue(name, '', parentEvaluateName); } } diff --git a/src/chrome/chromeDebugSession.ts b/src/chrome/chromeDebugSession.ts index 37e336e36..2ab97b259 100644 --- a/src/chrome/chromeDebugSession.ts +++ b/src/chrome/chromeDebugSession.ts @@ -113,6 +113,10 @@ export class ChromeDebugSession extends LoggingDebugSession implements IObservab telemetry.reportEvent(ErrorTelemetryEventName, properties); }; + // While using the debug adapter in a debug server, we create several connections. To prevent accumulating listeners we remove existing listeners before adding new ones + process.removeAllListeners('uncaughtException'); + process.removeAllListeners('unhandledRejection'); + process.on('uncaughtException', (err: any) => { reportErrorTelemetry(err, 'uncaughtException');