-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Improve error message when scriptInfo is missing in mapTextChangeToCodeEdit #28258
Conversation
src/server/editorServices.ts
Outdated
@@ -1966,6 +1966,11 @@ namespace ts.server { | |||
return configProject && configProject.getCompilerOptions().configFile; | |||
} | |||
|
|||
/* @internal */ | |||
allScriptInfoFileNamesForDebug(): ReadonlyArray<string> { | |||
return arrayFrom(this.filenameToScriptInfo.keys()); |
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.
I think we should have both filename and path print instead of just path to figure out if there is mismatch in casing that could cause this.
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.
So the keys of filenameToScriptInfo
are paths and not filenames? I was assuming the key to this map was the same as the value's .fileName
property?
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.
No it is path.
src/server/editorServices.ts
Outdated
return scriptInfo.getDefaultProject(); | ||
} | ||
else { | ||
this.logger.msg(`Cannot find ${fileName} in ${JSON.stringify(this.allScriptInfoFileNamesForDebug)}`, Msg.Err); |
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.
Needs to be this.allScriptInfoFileNamesForDebug()
src/server/editorServices.ts
Outdated
/* @internal */ | ||
allScriptInfoFileNamesForDebug(): ReadonlyArray<{ readonly path: string, readonly fileName: string }> { | ||
const out: { readonly path: string, readonly fileName: string }[] = []; | ||
this.filenameToScriptInfo.forEach((scriptInfo, path) => { |
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.
May be use arrayFrom ?
src/server/session.ts
Outdated
return Errors.ThrowNoProject(); | ||
} | ||
return symLinkedProjects ? { projects: projects!, symLinkedProjects } : projects!; // TODO: GH#18217 | ||
} | ||
|
||
private logErrorForScriptInfoNotFound(fileName: string): void { |
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.
Move this to editorServices and use it in all locations?
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.
Need to update API as the build will fail without it but everything else is good.
Should help diagnose #28233
Putting the text in a log message instead of in the exception text to avoid putting PII in exception text.