microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.33k stars 12.53k forks source link

TypeError: path.charCodeAt is not a function in getEncodedRootLength #51518

Closed xBoyMinemc closed 1 year ago

xBoyMinemc commented 2 years ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. open my work,some ts file
  2. Press ctrl and click on some variable, or just mouse over, to see information about the variable (Indefinite time, sometimes a few minutes, sometimes longer)
  3. image
  4. Prompt to crash five times, no more restarts

normal : image

crash : image
image

vscodenpa commented 2 years ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.73.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

xBoyMinemc commented 2 years ago

image Thanks, just finished the update, I'll program and wait for it happen again

xBoyMinemc commented 2 years ago

image

image

maybe restart again?

xBoyMinemc commented 2 years ago

https://user-images.githubusercontent.com/86919167/201116082-0b80a17d-0a38-462a-a248-100701f38a41.mp4 (did the video break?i cant load it)

Please teach me how to provide more information

mjbvz commented 2 years ago

Does this reproduce in the latest VS Code insiders build with all extensions disabled?

xBoyMinemc commented 2 years ago

yes, 1.17.31 Updated eight hours ago,and disable all extensions, Even includes language adaptation packages

How can I provide more useful information next?


xBoyMinemc commented 2 years ago

maybe reinstall? i updataed by VS Code setting.

mjbvz commented 2 years ago

Please test in VS Code insiders. This should be VS Code 1.74

xBoyMinemc commented 2 years ago

funny,look this ,but before 4.8.4 image i just do no thing and ready to Update in VS Code insiders.

OHHH VS Code insiders work well, but I'll watch for a few days

--thanks

xBoyMinemc commented 2 years ago

ohhh,funny again image VS Code insiders work wrong :(
i just want to finsh my toys

xBoyMinemc commented 2 years ago

TS Server fatal error: path.charCodeAt is not a function

Type: Bug

❗️❗️❗️ Please fill in the sections below to help us diagnose the issue ❗️❗️❗️

TypeScript Version: 4.9.2-rc

Steps to reproduce crash

1.i do no thing
2.just open my VSC with my working files 3.https://github.com/microsoft/TypeScript/issues/51518

TS Server Log

❗️ Server logging disabled. To help us fix crashes like this, please enable logging by setting:

"typescript.tsserver.log": "verbose"

After enabling this setting, future crash reports will include the server log.

TS Server Error Stack

Server: semantic

TypeError: path.charCodeAt is not a function
    at getEncodedRootLength (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:7693:24)
    at getRootLength (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:7770:26)
    at combinePaths (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:7964:26)
    at getPathComponents (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:7875:16)
    at getNormalizedPathComponents (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:8003:37)
    at Object.getNormalizedAbsolutePath (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:8007:42)
    at normalizeNonListOptionValue (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42889:24)
    at normalizeOptionValue (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42885:16)
    at c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42878:70
    at Object.map (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:460:29)
    at normalizeOptionValue (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42878:37)
    at Object.onSetValidOptionKeyValueInParent (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42702:46)
    at _loop_4 (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:41961:56)
    at convertObjectLiteralExpressionToJson (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:41979:17)
    at convertPropertyValueToJson (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42038:46)
    at _loop_4 (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:41948:29)
    at convertObjectLiteralExpressionToJson (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:41979:17)
    at convertPropertyValueToJson (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42038:46)
    at convertToObjectWorker (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:41920:16)
    at convertConfigFileToObject (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:41900:16)
    at parseOwnConfigOfJsonSourceFile (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42723:20)
    at parseConfig (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42619:13)
    at parseJsonConfigFileContentWorker (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42435:28)
    at Object.parseJsonSourceFileConfigFileContent (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:42398:22)
    at ProjectService.ensureParsedConfigUptoDate (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:177091:44)
    at ProjectService.loadConfiguredProject (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:177036:52)
    at ProjectService.createAndLoadConfiguredProject (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:177017:22)
    at ProjectService.createLoadAndUpdateConfiguredProject (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:177022:36)
    at ProjectService.assignProjectToOpenedScriptInfo (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:178108:44)
    at c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:178448:97
    at Object.flatMap (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:524:25)
    at ProjectService.applyChangesInOpenFiles (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:178448:41)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:179820:46)
    at c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:182013:96
    at Session.executeWithRequestId (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:182004:28)
    at Session.executeCommand (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:182013:41)
    at Session.onMessage (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:182041:35)
    at process.<anonymous> (c:\Users\云梦\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\node_modules\typescript\lib\tsserver.js:186197:31)
    at process.emit (node:events:526:28)
    at emit (node:internal/child_process:938:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

VS Code version: Code - Insiders 1.74.0-insider (ef415578d1b1019db585718968a303eeca4b8979, 2022-11-11T05:19:14.666Z) OS version: Windows_NT x64 10.0.19044 Modes: Unsupported Sandboxed: Yes

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 5800H with Radeon Graphics (16 x 3194)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|undefined| |Memory (System)|15.36GB (6.22GB free)| |Process Argv|--crash-reporter-id cc0b8585-06d6-4f4a-a213-2b30959be61a| |Screen Reader|no| |VM|0%|
Extensions: none
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256198 vslsvsres303:30308271 pythonvspyl392:30422396 pythontb:30258533 pythonptprofiler:30281269 vshan820:30294714 pythondataviewer:30285072 vscod805:30301674 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593cf:30376535 pythonvs932:30404738 cppdebug:30492333 vsclangdf:30492506 c4g48928:30535728 dsvsc012:30540252 pynewext54:30602959 pylantcb52:30590116 vsccc:30564266 pyindex848:30577858 nodejswelcome1:30587009 gswce1:30602633 34cci188:30599831 pyind779cf:30600160 dbltrim-noruby:30604474 ```
xBoyMinemc commented 2 years ago

and>>> image image what's happen? CPU BOOM

after kill it: image

xBoyMinemc commented 2 years ago

any some body here?

Can't work by this for six days ):

ahilmathew commented 2 years ago

Having the same issue - image

mjbvz commented 2 years ago

@xBoyMinemc Please try collecting the TS Server log from the crashed instance:

  1. Set "typescript.tsserver.log": "verbose"
  2. Restart VS Code and reproduce the problem
  3. Open the TypeScript section of the output panel
  4. At the very top, find the first line that prints to path to the semantic error log file. It should look something like:

    [Info  - 19:54:59.247] <semantic> Log file: /Users/matb/Library/Application Support/Code - Insiders/logs/20200213T104930/exthost55/vscode.typescript-language-features/tsserver-log-ZT2zau/tsserver.log

    That file contains the typescript logs.

Please share this log so we can try to see why the server is crashing (and also so we can confirm that TS Server plugins are not causing this)

⚠️Warning: The TypeScript log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on Github, just let me know and we can arrange something else. On our side, we only use these logs to investigate issues like this

xBoyMinemc commented 2 years ago

log.zip

Personal computers, theoretically do not contain sensitive information

xBoyMinemc commented 2 years ago

and i think,,,,, image

CPU usage is high because log files are created continuously and some programs try to restart

DanielRosenwasser commented 2 years ago

This is because your package has a tsconfig.json with unterminated baseUrl and typeRoots properties:

{
    "compilerOptions": {
        "module": "commonjs",
        "lib": ["es6"],
        "target": "es6",
        "forceConsistentCasingInFileNames": true,
        "noEmit": true,
        "noImplicitAny": true,
        "noImplicitThis": true,
        "strictFunctionTypes": true,
        "strictNullChecks": true,

        // !!!!!
        "baseUrl": "..,
        "typeRoots": ["..],

        "types": []
    },
    "files": [
        "index.d.ts"
    ]
  }

On our side the fix is easy - we need to validate that when we check option.isFilePath that the current value is actually a string.

-    if (option.isFilePath) {
+    if (option.isFilePath && typeof value === "string") {
xBoyMinemc commented 2 years ago

oh!Who says no hero in the human !!!!!!!!!!!!!!!

I will continue to use it,and close it in a few days

---thanks

DanielRosenwasser commented 2 years ago

This is still a bug in our compiler - please leave this open until it's resolved.

iisaduan commented 1 year ago

The crash was fixed with #53331

sunnywilson93 commented 5 months ago

Upgrade typescript to v5+. Apart from this, if you're using any bundlers (e.g., Rollup, Webpack), don't forget to upgrade their TypeScript-related packages as well. I had to upgrade rollup-plugin-ts.