Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Fix #212 - stacks not sourcemapped when they come from a log message
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Jun 22, 2017
1 parent da70a69 commit afe7d1d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/chrome/chromeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,15 +821,21 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
protected onConsoleAPICalled(params: Crdp.Runtime.ConsoleAPICalledEvent): void {
const result = formatConsoleArguments(params);
if (result) {
const category = result.isError ? 'stderr' : 'stdout';
this.logObjects(result.args, category);
this.logObjects(result.args, result.isError);
}
}

private logObjects(objs: Crdp.Runtime.RemoteObject[], category: string): void {
private async logObjects(objs: Crdp.Runtime.RemoteObject[], isError = false): Promise<void> {
const category = isError ? 'stderr' : 'stdout';

// Shortcut the common log case to reduce unnecessary back and forth
if (objs.length === 1 && objs[0].type === 'string') {
const e = new OutputEvent(objs[0].value + '\n', category);
let msg = objs[0].value;
if (isError) {
msg = await this.mapFormattedException(msg);
}

const e = new OutputEvent(msg + '\n', category);
this._session.sendEvent(e);
return;
}
Expand Down Expand Up @@ -865,7 +871,7 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter {
const clientPath = this._pathTransformer.getClientPathFromTargetPath(linePath);
const mapped = await this._sourceMapTransformer.mapToAuthored(clientPath || linePath, adjustedLineNum, columnNum);

if (mapped && mapped.source && utils.isNumber(mapped.line) && utils.isNumber(mapped.column)) {
if (mapped && mapped.source && utils.isNumber(mapped.line) && utils.isNumber(mapped.column) && utils.existsSync(mapped.source)) {
this._lineColTransformer.mappedExceptionStack(mapped);
exceptionLines[i] = exceptionLines[i].replace(
`${linePath}:${lineNum}:${columnNum}`,
Expand Down

0 comments on commit afe7d1d

Please sign in to comment.