Skip to content

Dont create empty diagnostic messages #1114

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

Merged

Conversation

mediremi
Copy link
Contributor

@mediremi mediremi commented Aug 2, 2025

VS Code throws a TypeError: message not sent error if a diagnostic message is blank:

https://github.com/microsoft/vscode/blob/3aef8be5e46aa7e97e8b0ed115f6147cd0b24634/src/vs/workbench/api/common/extHostTypes.ts#L1183-L1185

We create diagnostics with empty messages if diagnosticMessage is an empty array, which happens if parsedDiagnostic.content is empty or has only 1 element:

let [fileAndRangeLine, ...diagnosticMessage] = parsedDiagnostic.content;
let { file, range } = parseFileAndRange(fileAndRangeLine);
if (result[file] == null) {
result[file] = [];
}
// remove start and end whitespaces/newlines
let message = diagnosticMessage.join("\n").trim()

The compiler log message FAILED: cannot make progress due to previous errors. is converted to a diagnostic message with content: [line], which triggers this condition:

} else if (line.startsWith("FAILED:")) {
// File with a self cycle
parsedDiagnostics.push({
code: undefined,
severity: t.DiagnosticSeverity.Error,
tag: undefined,
content: [line],
});

In addition to adding a check for message != "" before creating a diagnostic message, I've also changed the compiler log output parser to skip the following errors messages:

  • FAILED: cannot make progress due to previous errors
  • FAILED: dependency cycle

These errors don't currently contain filepath/range information and so we cannot create diagnostic messages for them anyway (though with some tweaking on the compiler side, we might be able to output filepaths for dependency cycle errors.)

@zth
Copy link
Collaborator

zth commented Aug 2, 2025

Side note - outputting dependency issues in the compiler would be a massive (and necessary) improvement.

@mediremi mediremi marked this pull request as ready for review August 2, 2025 13:23
@zth zth merged commit e47bc54 into rescript-lang:master Aug 2, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants