Skip to content

Commit 41414c2

Browse files
TypeScript ToolsTypeScript Tools
authored andcommitted
Strip a path list out of an error message
The error, which happens quite frequently, contains an excessively long path list. The message itself was cleaned up in microsoft/TypeScript#32785 but we add some additional filtering to the editor since older server versions are still in use.
1 parent 5ea298a commit 41414c2

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

extensions/typescript-language-features/src/tsServer/serverError.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ export class TypeScriptServerError extends Error {
4040
if (errorText) {
4141
const errorPrefix = 'Error processing request. ';
4242
if (errorText.startsWith(errorPrefix)) {
43-
const prefixFreeErrorText = errorText.substr(errorPrefix.length);
43+
let prefixFreeErrorText = errorText.substr(errorPrefix.length);
44+
45+
// Prior to https://github.com/microsoft/TypeScript/pull/32785, this error
46+
// returned and excessively long and detailed list of paths. Since server-side
47+
// filtering doesn't have sufficient granularity to drop these specific
48+
// messages, we sanitize them here.
49+
if (prefixFreeErrorText.indexOf('Could not find sourceFile') >= 0) {
50+
prefixFreeErrorText = prefixFreeErrorText.replace(/ in \[[^\]]*\]/g, '');
51+
}
52+
4453
const newlineIndex = prefixFreeErrorText.indexOf('\n');
4554
if (newlineIndex >= 0) {
4655
// Newline expected between message and stack.

0 commit comments

Comments
 (0)