Skip to content

Commit 4992b8c

Browse files
authored
fix: stack traces logged immediately before exit not being sourcemapped (#1358)
* fix: stack traces logged immediately before exit not being sourcemapped Fixes microsoft/vscode#142197 * fixup! tests
1 parent 063090a commit 4992b8c

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
1010
- fix: allow overriding resolution of workspaceFolder in pathMapping ([#1308](https://github.com/microsoft/vscode-js-debug/issues/1308))
1111
- fix: extraneous warnings when restarting debugging ([vscode#156432](https://github.com/microsoft/vscode/issues/156432))
1212
- fix: webview debugging ([#1344](https://github.com/microsoft/vscode-js-debug/issues/1344))
13+
- fix: stack traces logged immediately before exit not being sourcemapped ([vscode#142197](https://github.com/microsoft/vscode/issues/142197))
1314

1415
## v1.70 (July 2022)
1516

src/adapter/console/exceptionMessage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class ExceptionMessage extends TextualMessage<Cdp.Runtime.ExceptionDetail
5555
const stackTrace = this.stackTrace(thread);
5656
const args = this.event.exception && !preview.stackTrace ? [this.event.exception] : [];
5757

58-
// If there is a stacktrace in the exception message, beautiful its paths.
58+
// If there is a stacktrace in the exception message, beautify its paths.
5959
// If there isn't (and there isn't always) then add one.
6060
if (StackTraceParser.isStackLike(message)) {
6161
message = await thread.replacePathsInStackTrace(message);

src/adapter/console/textualMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export abstract class TextualMessage<T extends { stackTrace?: Cdp.Runtime.StackT
110110
if (args.some(a => a.subtype === 'error') || StackTraceParser.isStackLike(output)) {
111111
await this.getUiLocation(thread); // ensure the source is loaded before decoding stack
112112
output = await thread.replacePathsInStackTrace(output);
113+
includeStackInVariables = true;
113114
}
114115

115116
const outputVar = thread.replVariables.createVariableForOutput(

src/adapter/threads.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -992,18 +992,20 @@ export class Thread implements IVariableStoreLocationProvider {
992992
*/
993993
async dispose() {
994994
this.disposed = true;
995-
this._removeAllScripts(true /* silent */);
996995
for (const [debuggerId, thread] of Thread._allThreadsByDebuggerId) {
997996
if (thread === this) Thread._allThreadsByDebuggerId.delete(debuggerId);
998997
}
999998

1000-
this._executionContextsCleared();
1001-
1002999
if (this.console.length) {
10031000
await new Promise(r => this.console.onDrained(r));
10041001
}
10051002
this.console.dispose();
10061003

1004+
// Wait for consoles to log before disposing scripts to ensure locations map
1005+
// https://github.com/microsoft/vscode/issues/142197
1006+
this._removeAllScripts(true /* silent */);
1007+
this._executionContextsCleared();
1008+
10071009
// Send 'exited' after all other thread-releated events
10081010
await this._dap.with(dap =>
10091011
dap.thread({

src/test/console/console-format-popular-types.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ Evaluating: 'console.log([throwingLengthGetter])'
203203
stdout> > (1) [{…}]
204204

205205
Evaluating: 'console.log(domException())'
206-
stdout> > DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. {stack: <accessor>, code: 8, name: 'NotFoundError', message: 'Failed to execute 'removeChild' on 'Node': T…e to be removed is not a child of this node.'}
206+
stdout>
207+
> DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. {stack: <accessor>, code: 8, name: 'NotFoundError', message: 'Failed to execute 'removeChild' on 'Node': T…e to be removed is not a child of this node.'}
207208

208209
Evaluating: 'console.log([domException()])'
209210
stdout> > (1) [DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of t…]

0 commit comments

Comments
 (0)