Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: watch expressions are not updated properly #11955

Closed
vince-fugnitto opened this issue Dec 5, 2022 · 1 comment · Fixed by #14874
Closed

debug: watch expressions are not updated properly #11955

vince-fugnitto opened this issue Dec 5, 2022 · 1 comment · Fixed by #14874
Labels
debug issues that related to debug functionality

Comments

@vince-fugnitto
Copy link
Member

Bug Description:

There is an issue with watch expressions not being updated in the debug-view which causes a difference in behavior with vscode and user expectations.

For example:

If we add a watch expression with no debug session present, we correctly get information that the expression is not available.

image

However, if we start a debug session and hit the breakpoint (making the variable value assigned), the watch expression is not updated:

image

If we edit the watch expression with the same name (value) then it gets updated:

image

Steps to Reproduce:

  1. start the application using theia as a workspace
  2. open the cli.spec.ts file and set a breakpoint at line 38 (after const value)
  3. open the debug-view and add a watch expression for value
  4. the watch expression should include the message "not available"
  5. start the debug session with "run mocha tests"
  6. the breakpoint should be hit, but the watch expression is not updated
  7. right-click the value watch expression, select "edit expression" and press "enter" (keeping value as a name)
  8. the watch expression will be properly updated
@vince-fugnitto vince-fugnitto added the debug issues that related to debug functionality label Dec 5, 2022
@eneufeld eneufeld mentioned this issue Feb 7, 2025
66 tasks
@kittaakos
Copy link
Contributor

This is because the very first 'evaluate' happens too early, and the VS Code debug JS extension does not even reject that request: https://github.com/microsoft/vscode-js-debug/blob/d7730405d64e81eb364f76ea38efb7c93a5f877d/src/dap/connection.ts#L172

Since there is a queue of promises to update the watch expression in Theia, and the first neither rejects nor resolves, then the next updates will also wait forever:

protected refreshWatchExpressions = debounce(() => {
this.refreshWatchExpressionsQueue = this.refreshWatchExpressionsQueue.then(async () => {
try {
for (const watchExpression of this.watchExpressions) {
await watchExpression.evaluate();
}
} catch (e) {
console.error('Failed to refresh watch expressions: ', e);
}
});
}, 50);

If the 'evaluate' promises are not queued, the console error can be seen in the backend log, but there is no rejection:

2025-02-07T14:13:38.292Z root INFO REFRESHING WATCH EXPRESSIONS 5
2025-02-07T14:13:38.293Z root INFO EVALUATING WATCH EXPRESSION 5 nestedObject
2025-02-07T14:13:38.293Z root INFO REFRESHING WATCH EXPRESSIONS 5
2025-02-07T14:13:38.293Z root INFO EVALUATING WATCH EXPRESSION 5 nestedObject
2025-02-07T14:13:38.294Z root ERROR [hosted-plugin: 91150] Unknown request: evaluate
Unknown request: evaluate
2025-02-07T14:13:38.480Z root INFO [hosted-plugin: 91150] Creating local connection: f1d3f043-c7f9-4446-8535-22b95602abc1
2025-02-07T14:13:38.483Z root INFO [hosted-plugin: 91150] starting debug adapter session 'f1d3f043-c7f9-4446-8535-22b95602abc1'
2025-02-07T14:13:38.486Z root INFO [hosted-plugin: 91150] Creating plugin connection: f1d3f043-c7f9-4446-8535-22b95602abc1
2025-02-07T14:13:38.607Z root INFO REFRESHING WATCH EXPRESSIONS 6
2025-02-07T14:13:38.607Z root INFO EVALUATING WATCH EXPRESSION 6 nestedObject
2025-02-07T14:13:38.607Z root INFO REFRESHING WATCH EXPRESSIONS 6
2025-02-07T14:13:38.607Z root INFO EVALUATING WATCH EXPRESSION 6 nestedObject
2025-02-07T14:13:38.611Z root INFO DID EVALUATE WATCH EXPRESSION 6 nestedObject
2025-02-07T14:13:38.611Z root INFO DID REFRESH WATCH EXPRESSIONS 6
2025-02-07T14:13:38.611Z root INFO DID EVALUATE WATCH EXPRESSION 6 nestedObject
2025-02-07T14:13:38.611Z root INFO DID REFRESH WATCH EXPRESSIONS 6
watch_part1.mov
watch_part2.mov

Theia can fix it quickly. Do not queue or time out. The more challenging solution is to figure out why JS debug cannot accept the evaluate command, although the adapter has already sent the initialized event to the client.

kittaakos added a commit to kittaakos/theia that referenced this issue Feb 7, 2025
The `vscode-js-debug` does not reject when the evaluate request arrives
too early to the debug adapter and the evaluate handler is not yet
registered.

Ref: https://github.com/microsoft/vscode-js-debug/blob/d7730405d64e81eb364f76ea38efb7c93a5f877d/src/dap/connection.ts#L172

If the first evaluate request never rejects nor resolves, none of the
following evaluate requests will as they are queued, making the Theia
UI never update.

This commit adds a 1000ms timeout to the evaluate DAP call.

Note that the VS Code Debug JS extension cannot accept the evaluate
request despite it already sent the initialized to the client.

Closes eclipse-theia#11955
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug issues that related to debug functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants