Remove redundant sendVarDelete call that throws an error#512
Conversation
|
Hi @jonahgraham , I created the Pull Request to solve the error of "object not found" in calling sendVarDelete after using removeVar(...) method, it causes duplicated deleting. Could you please help me to review it? (I add the test script also in doEvaluateRequest.spec.ts file) Thank you so much. |
jonahgraham
left a comment
There was a problem hiding this comment.
Can you provide a way to reproduce this error? I still don't understand how users see this problem. It also seems that none of the tests cover these lines of code.
I have provided some line comments, but the key thing I don't understand is whether the sendVarDelete actually can succeed. And if it can never succeed, then why can't we just delete it.
Thank you @jonahgraham for reviewing and pointing out issues. |
jonahgraham
left a comment
There was a problem hiding this comment.
I was pinged offline about this and realized that I had not submitted my below review. To avoid further delays I will apply the removal of console.log myself and this can be merged.
52a7bdd to
a2fc09a
Compare
|
Updated title and original description to be: This sendVarDelete is rarely reachable, generally only reachable when the same variable name is used in two different scopes within the same method. See use of When debugging such code, and the Included in this change is a test that demonstrates the use case, the new test |
This sendVarDelete is rarely reachable, generally only reachable when the same variable name is used in two different scopes within the same method. See use of `x` variable in src/integration-tests/test-programs/watch_local_scope_transition.c for an example. When debugging such code, and the `x` was in the watch window, the now removed sendVarDelete would run, but the var was already deleted by the varManager.removeVar on the line above. So the sendVarDelete would generate an exception, causing the `x` not to be evaluated. Included in this change is a test that demonstrates the use case, the new test `evaluate request - watch local variable across lexical scope transition` in evaluate.spec.ts.
a2fc09a to
feed9bd
Compare
this is the updated description and summary, as this change was progressed the design and implementation changed substantially. See collapsed section below for original description.
This sendVarDelete is rarely reachable, generally only reachable when the same variable name is used in two different scopes within the same method. See use of
xvariable insrc/integration-tests/test-programs/watch_local_scope_transition.c for an example.
When debugging such code, and the
xwas in the watch window, the now removed sendVarDelete would run, but the var was already deleted by the varManager.removeVar on the line above. So the sendVarDelete would generate an exception, causing thexnot to be evaluated.Included in this change is a test that demonstrates the use case, the new test
evaluate request - watch local variable across lexical scope transitionin evaluate.spec.ts.Original message
Summary: Improvement/wrap send var delete in try/catch after remove var in do evaluate request
For ECA reasons, this is a continuation of #509
Background: removeVar(...) called sendVarDelete(...) inside itself.
In case of doEvaluateRequest(...) method, it will throw "object not found" error when calling sendVarDelete(...) after removeVar(...).
Solution: add try/catch to safely wrap the sendVarDelete(...) to swallow the "object not found" error.
Other errors still be catch in catch (err) block in the end of doEvaluateRequest(...) as currently.
Reason of NOT removing sendVarDelete(...) in doEvaluateRequest(...):
1/ In future, if a person removes sendVarDelete(...) inside removeVar(...) -> sendVarDelete(...) still need to be called after removeVar(...) - same as current development.
2/ Why I did not remove sendVarDelete(...) inside removeVar(...) : because removeVar(...) is used at other place , also maybe used in third party code. If I change removeVar(...) it will impact their implementation.