-
Notifications
You must be signed in to change notification settings - Fork 304
Don’t crash sourcekit-lsp if a known message is missing a field #1154
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
Don’t crash sourcekit-lsp if a known message is missing a field #1154
Conversation
@swift-ci Please test |
case .unknown: | ||
// We don't know what has gone wrong. This could be any level of badness. Inform the user about it. | ||
logger.fault("ignoring unknown message") | ||
sendMessageDecodingErrorNotificationToClient(message: "sourcekit-lsp failed to decode a message") |
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.
Are you purposefully making this slightly different to the catch case so that we know the difference from eg. a screenshot?
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.
Yes, exactly.
// We failed to parse the message header. There isn't really much we can do to recover because we lost our | ||
// anchor in the stream where new messages start. Crashing and letting ourselves be restarted by the client is | ||
// probably the best option. | ||
sendMessageDecodingErrorNotificationToClient(message: "Failed to find next message in connection to editor.") |
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.
The .
will cause a ..
as sendMessageDecodingErrorNotificationToClient
adds a .
itself
5527188
to
eb28054
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
} catch { | ||
// We don't know what has gone wrong. This could be any level of badness. Inform the user about it and ignore the | ||
// message. | ||
logger.fault("ignoring unknown message") |
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.
Missed one :)
Previously, we `fatalError`ing when `JSONDecoder` failed to decode a message from the client. Instead of crashing, try recovering from such invalid messages as best as possible. If we know that the state might have gotten out of sync with the client, show a notification message to the user, asking them to file an issue. rdar://112991102
eb28054
to
be42621
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
Previously, we
fatalError
ing whenJSONDecoder
failed to decode a message from the client. Instead of crashing, try recovering from such invalid messages as best as possible. If we know that the state might have gotten out of sync with the client, show a notification message to the user, asking them to file an issue.rdar://112991102