vscode-js-debug
vscode-js-debug copied to clipboard
Consider Source Map For Stack Traces
Sometimes, I see stack traces in the debug output:
ERR Cannot read properties of undefined (reading 'read'): TypeError: Cannot read properties of undefined (reading 'read')
at Derived._computeFn (http://localhost:3000/src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditsView.ts?t=1740093639452:81:132)
at Derived._recomputeIfNeeded (http://localhost:3000/src/vs/base/common/observableInternal/derived.ts?t=1740052750953:213:27)
at Derived.get (http://localhost:3000/src/vs/base/common/observableInternal/derived.ts?t=1740052750953:191:14)
at Derived.readObservable (http://localhost:3000/src/vs/base/common/observableInternal/derived.ts?t=1740052750953:322:30)
at Derived.read (http://localhost:3000/src/vs/base/common/observableInternal/base.ts:27:21)
at Derived._computeFn (http://localhost:3000/src/vs/base/common/observableInternal/base.ts:55:27)
at Derived._recomputeIfNeeded (http://localhost:3000/src/vs/base/common/observableInternal/derived.ts?t=1740052750953:213:27)
at Derived.get (http://localhost:3000/src/vs/base/common/observableInternal/derived.ts?t=1740052750953:191:14)
at Derived.readObservable (http://localhost:3000/src/vs/base/common/observableInternal/derived.ts?t=1740052750953:322:30)
at Derived.read (http://localhost:3000/src/vs/base/common/observableInternal/base.ts:27:21)
However, it is difficult to act on them, as they refer to the out source, and not the original typescript files. It would be very helpful if the source map was considered for these stacktraces.
Some implementation ideas:
- Detect stack-like strings and rewrite them before they are written to the debug console
- Implement a link detector in the debug console that opens the source mapped location (e.g.
./src/main.ts) instead of the link directly (http://localhost:3000/src/main.ts) - Add
[[Location]]to the view when anErroris viewed, similar to functions (though this wouldn't work out of the box, as not the error object is logged, but the error string). - Register a cdp binding so that the debugee can translate stack traces on their own (if the binding is present). Additionally, the debugger could inject JS code that patches Error.stack to automatically consider stack traces