-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
"Cannot read property 'lastIndexOf' of undefined" error in tsserver.js #43105
Comments
@RyanCavanaugh is there a chance to reprioritize this issue: there is almost 20 reports (and growing) in just a week after release VS Code stable release? Is there anything we should ask reporters to provide in order help with investigation? |
I wonder if this is a Windows only issue? I can't repro with the steps above ( tsserver: 4.3.0-dev.20210311 ) Judging on diffs - maybe this PR? #42150 |
Looks likely it's windows related, I'm not familiar enough with tsserver.js to know exactly what's going on, but it looks like the undefined value originates here: Where
and
So edit: The |
Yes, looks like it's Windows specific: I was able to reproduce in on Windows but not under WSL2 Still reproducible in latest nightly Did several checks and looks like:
First bad is from December, but this PR was merged on January 20, so shouldn't be related. |
Yes, looks like it's Windows specific: I was able to reproduce in on Windows but not under WSL2 Still reproducible in latest nightly Did several checks and looks like:
First bad is from December, but this PR was merged January 20, so shouldn't be related. |
@orta @RyanCavanaugh We've seen a few reports of they on the VS Code side. Is this something that we could look into for a TS 4.2 recovery build if the fix isn't too risky? |
Just got back from a week off, I'll poke Daniel/Ryan about this issue and // Difference case for C (as is the reference)
assert.deepEqual(ts.getPathComponents("C:/Projects/OmniSharp/omnisharp-vscode/src/vscodeAdapter.ts", "c:/Projects/OmniSharp/omnisharp-vscode"),
["C:/", "Projects", "OmniSharp", "omnisharp-vscode", "src", "vscodeAdapter.ts"]);
// Same case of "c"
assert.deepEqual(ts.getPathComponents("c:/Projects/OmniSharp/omnisharp-vscode/src/vscodeAdapter.ts", "c:/Projects/OmniSharp/omnisharp-vscode"),
["c:/", "Projects", "OmniSharp", "omnisharp-vscode", "src", "vscodeAdapter.ts"]); And same for when they are normalized: // Same case of "c"
assert.deepEqual(ts.getPathComponents(ts.getNormalizedAbsolutePath("c:/Projects/OmniSharp/omnisharp-vscode/src/vscodeAdapter.ts", "c:/Projects/OmniSharp/omnisharp-vscode")),
["c:/", "Projects", "OmniSharp", "omnisharp-vscode", "src", "vscodeAdapter.ts"]);
// Difference case for C
assert.deepEqual(ts.getPathComponents(ts.getNormalizedAbsolutePath("C:/Projects/OmniSharp/omnisharp-vscode/src/vscodeAdapter.ts", "c:/Projects/OmniSharp/omnisharp-vscode")),
["C:/", "Projects", "OmniSharp", "omnisharp-vscode", "src", "vscodeAdapter.ts"]); Looking like Given the time range when this was introduced, and that is it OS specific, it is likely that #41292 is probably the cause |
Confirmed that converting: - const realpathSync = _fs.realpathSync.native ?? _fs.realpathSync;
+ const realpathSync = _fs.realpathSync; Which effectively undoes #41292 but does fix my repro, now to try figure out what triggers the difference in behavior |
Possibly unrelated, but there's a typo in the path here: https://github.com/OmniSharp/omnisharp-vscode/blob/a2c3a9d5024399ee65f77992dd81b63831d5cca6/test/unitTests/logging/OmnisharpChannelObserver.test.ts#L6 Edit: Fixing the typo mitigates the issue on my box. |
So, obviously, the path [Not fully confirmed] Downstream, we assume the path is in How is |
Filed #43342. Still investigating why the reduced repro doesn't crash the server. Edit: Looks like you need to have package.json and node_modules for the repro. I guess that makes sense, with a path in auto-imports. Edit 2: node_modules\microsoft.aspnetcore.razor.vscode is important, for some reason |
Reduced repro ./tsconfig.json {
} ./package.json {
"name": "csharp",
"version": "1.23.10",
"dependencies": {
"microsoft.aspnetcore.razor.vscode": "6"
}
} ./src/vscodeAdapter.ts export {} ./test/unitTests/logging/OmnisharpChannelObserver.test.ts import '.,/../../src/vscodeAdapter'; ./node_modules/microsoft.aspnetcore.razor.vscode/package.json {
"name": "microsoft.aspnetcore.razor.vscode",
"version": "6.0.0-alpha.1.20575.5",
"types": "./extension.d.ts"
} ./node_modules/microsoft.aspnetcore.razor.vscode/extension.d.ts export {} |
The bug - flagging a file as a symlink when it's not - applies more generally, but I think the crash will only happen if one of the root files is also resolved via a node_modules path (and there's an npm module with types for auto-import to pick up). |
Looks like 175K telemetry hits in the last day. (!!) Edit: but they're from only 246 distinct machines. |
@sheetalkamat, @orta and I started trying to updating this location to be case-sensitivity aware by making |
Result of module resolution should not be canonicalized.. you should canonicalize use instead. Since users can implement host providing custom resolution. Look at https://github.com/microsoft/TypeScript/blob/master/src/compiler/program.ts#L850 where host cannot assume everything will have extension. |
Just a quick update on scheduling: last week we agreed to push this to 4.3 since telemetry shows that a limited number of machines are hitting this. If you are impacted by this bug, once this issue is closed you should be able to install JavaScript and TypeScript nightly extension to pick up a fix instead of waiting on VS Code to pick up TS 4.3 |
I'm not sure I can be of much help here, but I want to let you all know that I've just gotten this error on a Mac. I've opened issue 128183 where you can see the stacktrace |
@Stupidism I'm actually not sure why this bug is still open, I believe the change that caused this issue was reverted in 4.2.4 and, I assume, 4.3. For November, we're attempting to re-implement the change without this bug. |
@orta @DanielRosenwasser Any reason to keep this bug open? |
Nope, yeah I agree - it should be closed |
Just to flag i had this same error on version 4.4.2 on Mac OS 11.5.2. Downgraded to 4.3.5 and error not present. |
@leanne1 Can you please provide more details? I don't believe the code responsible for the original issue was present in 4.4 (though an improved implementation is available in the nightlies). |
@amcasey I am experiencing this issue on 4.4.3, MacOS 11.5. From logging, seems to be caused by this bit of our tsconfig:
which I understand should be legit? This causes Update: |
the last version without the error for me is 4.2.4 (using typedoc on a subdirectory) |
We’re now tracking this at #44953—a full repro would still be helpful 🙏 |
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
💻 Steps to reproduce
This happens consistently for me in the OmniSharp/omnisharp-vscode repository, when opening a typescript file with 4.2 installed.
"typescript.tsdk": "C:\\Users\\phil\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib",
)🙁 Actual behavior
The TypeScript language server crashes. Attached is a sample log:
tsserver.zip
🙂 Expected behavior
It to not crash.
Related Issues
There's a couple of related issues in vscode repo such as microsoft/vscode#115905
The text was updated successfully, but these errors were encountered: