-
Notifications
You must be signed in to change notification settings - Fork 12.9k
deleteDeclaration
: don't crash on the top node.
#42968
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But moreover, we know that this is not from Emacs or fringe editors or general API misuse, because the telemetry comes to us via VS Code. I’m generally not a fan of silencing bugs we don’t understand. I’m not sure this is any better than crashing, because either way, the result is that we don’t generate a codefix. In either case, the user experience is either broken or completely unnoticeable (hard to say which); the only thing this PR does is prevents us from getting telemetry for it anymore.
063e360
to
b5cc450
Compare
A misbehaved client can sometimes cause the server to reach `deleteDeclaration` with the SourceFile, and it will crash due to no `node.parent`. I couldn't find a good way to create a test for it, but I could trigger it manually by having a file with just a `,`, and sending an explicit `getCodeFixes` command to the server with `errorCodes: [6133]`. Do three things to improve this: 1. `textChanges.ts`: if we get here with the root node, delete it instead of failing. 2. `fixUnusedIdentifier.ts`: check that we don't `delete` a node that is the whole source file, so the error is more focused (should have more similar failure stacks). 3. `session.ts`: when there was any failure in `getCodeFixes`, check if the input had a diag code that does not appear in the requested text range, and throw an error saying that the failure is probably a result of a bad request. Closes microsoft#33726 (probably not fixing it, but making it easier to find the cause)
A misbehaved client can sometimes cause the server to reach
deleteDeclaration
with the SourceFile, and it will crash due to nonode.parent
. I couldn't find a good way to create a test for it, butI could trigger it manually by having a file with just a
,
, andsending an explicit
getCodeFixes
command to the server witherrorCodes: [6133]
.Do three things to improve this:
textChanges.ts
: if we get here with the root node, delete itinstead of failing.
fixUnusedIdentifier.ts
: check that we don'tdelete
a node that isthe whole source file, so the error is more focused (should have more
similar failure stacks).
session.ts
: when there was any failure ingetCodeFixes
, check ifthe input had a diag code that does not appear in the requested text
range, and throw an error saying that the failure is probably a
result of a bad request.
Closes #33726 (probably not fixing it, but making it easier to find the cause)