microsoft / microsoft/vscode-js-debug
Custom toString causes non observable side effects when debugging
Open
@connor4312 is already working on this.
Since May 18, 2024.
under-discussion
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 373
- Avg merge
- 1d 9m
- Merged PRs (30d)
- 6
Description
Describe the bug
If a object has a toString method that produces side effects, the debugger triggers those side effects in a non observable way.
Seems related to #1296
To Reproduce
Place a breakpoint in the following code:
export class Foo {
#counter = 0;
get() {
console.log("Some side effects happen here");
// ^--- add breakpoint here
return this.#counter += 1;
}
toString () {
return String(this.get());
}
}
const foo = new Foo();
foo.get();
By the time the debugger stops at the breakpoint (before log should run), one log has already happened and the counter has increased.
VS Code Version: 1.89.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.