typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

[bug/lsp]panic: vfs: path "" is not absolute

Open emosheeep opened this issue 9 months ago • 13 comments

Don't know why does an empty string "" appear in the rootNames filed, which keeps crashing lsp server several times.

Info 14   [15:16:38.013] Open files: 
Info 14   [15:16:38.013] 	FileName: /Users/emosheep/projects/lvweb-tree/apps/ai-creator/src/services/digital-human-service/digital-human-service.ts ProjectRootPath: 
Info 14   [15:16:38.013] 		Projects: /Users/emosheep/projects/lvweb-tree/apps/ai-creator/tsconfig.json
Info 14   [15:16:38.013] 	FileName: /Users/emosheep/projects/lvweb-tree/apps/platform-business-ssr/src/hooks/use-user/login-plugins/ms-sdk/ms-sdk.tsx ProjectRootPath: 
Info 14   [15:16:38.013] 		Projects: /Users/emosheep/projects/lvweb-tree/apps/platform-business-ssr/tsconfig.json
Info 14   [15:16:38.014] getConfigFileNameForFile:: File: /Users/emosheep/projects/lvweb-tree/config/dist/types/constants/common/index.d.ts ProjectRootPath: :: Result: /Users/emosheep/projects/lvweb-tree/config/tsconfig.json
Info 15   [15:16:38.015] Creating KindConfiguredProject: /Users/emosheep/projects/lvweb-tree/config/tsconfig.json, currentDirectory: /Users/emosheep/projects/lvweb-tree/config
Info 16   [15:16:38.131] Config: /Users/emosheep/projects/lvweb-tree/config/tsconfig.json : {
      "options": {
        "allowUnreachableCode": false,
        "baseUrl": "/Users/emosheep/projects/lvweb-tree/config",
        "composite": true,
        "emitDecoratorMetadata": true,
        "declaration": true,
        "declarationDir": "/Users/emosheep/projects/lvweb-tree/config/dist/types",
        "declarationMap": true,
        "disableSourceOfProjectReferenceRedirect": false,
        "disableReferencedProjectLoad": true,
        "esModuleInterop": true,
        "experimentalDecorators": true,
        "lib": [
          "lib.esnext.d.ts",
          "lib.dom.d.ts",
          "lib.dom.iterable.d.ts"
        ],
        "module": 99,
        "moduleResolution": 100,
        "outDir": "/Users/emosheep/projects/lvweb-tree/config/dist",
        "resolveJsonModule": true,
        "rootDir": "/Users/emosheep/projects/lvweb-tree/config/src",
        "skipLibCheck": true,
        "strict": true,
        "sourceMap": true,
        "target": 99,
        "useDefineForClassFields": false,
        "verbatimModuleSyntax": true,
        "configFilePath": "/Users/emosheep/projects/lvweb-tree/config/tsconfig.json"
      },
      "projectReferences": [],
      "rootNames": [
        "/Users/emosheep/projects/lvweb-tree/config/src/apps.ts",
        "/Users/emosheep/projects/lvweb-tree/config/src/global.d.ts",
        "/Users/emosheep/projects/lvweb-tree/config/src/graphic.ts",
        "/Users/emosheep/projects/lvweb-tree/config/src/video-editor.ts",
        "",
        "/Users/emosheep/projects/lvweb-tree/config/src/config/commerce/commerce.ts",
        "/Users/emosheep/projects/lvweb-tree/config/src/config/domain/default.ts",
        "/Users/emosheep/projects/lvweb-tree/config/src/config/domain/ecommerce.ts",
        "/Users/emosheep/projects/lvweb-tree/config/src/config/favicon/default.ts",
        ...etc.
      ]
    }
panic: vfs: path "" is not absolute

goroutine 1 [running]:
github.com/microsoft/typescript-go/internal/vfs/internal.RootLength({0x0, 0x0})
	/Users/emosheep/projects/typescript-go/internal/vfs/internal/internal.go:22 +0x88
github.com/microsoft/typescript-go/internal/vfs/internal.SplitPath({0x0?, 0x1?})
	/Users/emosheep/projects/typescript-go/internal/vfs/internal/internal.go:29 +0x2c
github.com/microsoft/typescript-go/internal/vfs/internal.(*Common).RootAndPath(0x1038efe90, {0x0?, 0x1?})
	/Users/emosheep/projects/typescript-go/internal/vfs/internal/internal.go:36 +0x2c
github.com/microsoft/typescript-go/internal/vfs/internal.(*Common).ReadFile(0x30?, {0x0?, 0x9a928255d4e1418e?})
	/Users/emosheep/projects/typescript-go/internal/vfs/internal/internal.go:139 +0x20
github.com/microsoft/typescript-go/internal/vfs/osvfs.(*osFS).ReadFile(0x1038efe90, {0x0, 0x0})
	/Users/emosheep/projects/typescript-go/internal/vfs/osvfs/os.go:85 +0x6c
github.com/microsoft/typescript-go/internal/project.(*Service).getOrCreateScriptInfoWorker(0x140000a42c0, {0x0, 0x0}, {0x140631399e0, 0x23}, 0x0, 0x0, {0x0, 0x0}, 0x0)
	/Users/emosheep/projects/typescript-go/internal/project/service.go:301 +0x250
github.com/microsoft/typescript-go/internal/project.(*Service).getOrCreateScriptInfoNotOpenedByClient(...)
	/Users/emosheep/projects/typescript-go/internal/project/service.go:284
github.com/microsoft/typescript-go/internal/project.(*Service).loadConfiguredProject(0x140000a42c0, 0x14064b4dea0)
	/Users/emosheep/projects/typescript-go/internal/project/service.go:554 +0x4e4
github.com/microsoft/typescript-go/internal/project.(*Service).findCreateOrReloadConfiguredProject(0x140000a42c0, {0x1406313b840, 0x38}, 0x2, 0x0)
	/Users/emosheep/projects/typescript-go/internal/project/service.go:411 +0x118
github.com/microsoft/typescript-go/internal/project.(*Service).tryFindDefaultConfiguredProjectForOpenScriptInfo(0x140000a42c0, 0x140001ec6c0?, 0x2, 0x0)
	/Users/emosheep/projects/typescript-go/internal/project/service.go:423 +0x5c
github.com/microsoft/typescript-go/internal/project.(*Service).tryFindDefaultConfiguredProjectAndLoadAncestorsForOpenScriptInfo(...)
	/Users/emosheep/projects/typescript-go/internal/project/service.go:430
github.com/microsoft/typescript-go/internal/project.(*Service).assignProjectToOpenedScriptInfo(0x140000a42c0, 0x14002383b80)
	/Users/emosheep/projects/typescript-go/internal/project/service.go:437 +0x2c
github.com/microsoft/typescript-go/internal/project.(*Service).OpenFile(0x140000a42c0, {0x140752e9a47, 0x51}, {0x1405d43b980, 0x173}, 0x3, {0x0, 0x0})
	/Users/emosheep/projects/typescript-go/internal/project/service.go:112 +0xe4
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleDidOpen(0x140000a4210, 0x1400002d310?)
	/Users/emosheep/projects/typescript-go/internal/lsp/server.go:269 +0x19c
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleMessage(0x140000a4210, 0x140746d1140)
	/Users/emosheep/projects/typescript-go/internal/lsp/server.go:184 +0x1cc
github.com/microsoft/typescript-go/internal/lsp.(*Server).Run(0x140000a4210)
	/Users/emosheep/projects/typescript-go/internal/lsp/server.go:120 +0xb8
main.runLSP({0x14000010170, 0x1, 0x1})
	/Users/emosheep/projects/typescript-go/cmd/tsgo/lsp.go:52 +0x32c
main.main()
	/Users/emosheep/projects/typescript-go/cmd/tsgo/main.go:131 +0xb4
[Error - 15:16:38] Server process exited with code 2.
[Error - 15:16:38] The typescript-go-lsp server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

emosheeep avatar Mar 19 '25 07:03 emosheeep

Okay let me take a look on that

rezwanahmedsami avatar Mar 19 '25 08:03 rezwanahmedsami

@emosheeep You putting empty string on that ?

Or its generating empty string itself ?

rezwanahmedsami avatar Mar 19 '25 08:03 rezwanahmedsami

No, I haven't changed it. That’s what it looked like.

emosheeep avatar Mar 19 '25 09:03 emosheeep

This seems work, but only as a workaround, there're still some problems unresolved.

Image

https://github.com/microsoft/typescript-go/blob/f3cf27f6970fa98b26d9413dd160c4b864d570a2/internal/tsoptions/tsconfigparsing.go#L1506

emosheeep avatar Mar 19 '25 09:03 emosheeep

No, I haven't changed it. That’s what it looked like.

ok let me see

rezwanahmedsami avatar Mar 19 '25 09:03 rezwanahmedsami

@emosheeep

rezwan@rezwan:~/devwork/tsgo_test$ /home/rezwan/devwork/typescript-go/built/local/tsgo tsc --init

Why its not generating any tsconfig.json file ?

rezwanahmedsami avatar Mar 21 '25 13:03 rezwanahmedsami

That's not implemented yet. What does this have to do with your empty string panic?

jakebailey avatar Mar 21 '25 14:03 jakebailey

That's not implemented yet. What does this have to do with your empty string panic?

I want to face this empty string panic . So i can understand properly wheres the main issue

rezwanahmedsami avatar Mar 21 '25 15:03 rezwanahmedsami

@emosheeep give me your tsconfig.json, where where you getting issues

rezwanahmedsami avatar Mar 24 '25 08:03 rezwanahmedsami

Here you are, this is the tsconfig that the problem file belongs to.

{
  "extends": "@edenx/tsconfig/base",
  "compilerOptions": {
    "declaration": true,
    "jsx": "preserve",
    "baseUrl": "./",
    "paths": {
      "@/*": ["./src/*"],
      "@shared/*": ["./shared/*"],
      "@common/*": ["./common/*"],
      "@api/*": ["./api/*"],
      "@config/*": ["./config/*"]
    },
    "types": ["react", "react-dom"],
    "module":"nodenext",
    "moduleResolution": "nodenext",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "strictPropertyInitialization": false,
    "outDir": "dist",
    "declarationDir": "dist/types"
   },
  "include": ["src", "shared", "config", "server", "edenx.config.ts", "api"],
  "exclude": ["**/node_modules", "build"],
  "references": [
    {
      "path": "../../libs/component"
    },
    {
      "path": "../../libs/cookieConsent"
    },
    {
      "path": "../../libs/user"
    },
    {
      "path": "../../libs/reporter"
    },
    {
      "path": "../../libs/constants"
    },
    {
      "path": "../../libs/api"
    },
    {
      "path": "../../libs/hooks"
    },
    {
      "path": "../../libs/seo"
    },
    {
      "path": "../../libs/utils"
    },
    {
      "path": "../../libs/locale"
    },
    {
      "path": "../../libs/machine"
    },
    {
      "path": "../../libs/passport"
    },
    {
      "path": "../../plugins/infra"
    },
    {
      "path": "../../packages/global-request-hooks"
    },
    {
      "path": "../../config"
    },
    {
      "path": "../../packages/business/common-scss"
    },
    {
      "path": "../../packages/notify"
    }
  ]
}

emosheeep avatar Mar 24 '25 09:03 emosheeep

And this is <root>/config/tsconfig.json

{
  "extends": "./tsconfig.browser.json",
  "compilerOptions": {
    "outDir": "dist",
    "declarationDir": "dist/types",
    "baseUrl": ".",
    "rootDir": "src"
  },
  "exclude": ["dist", "node_modules"],
  "include": ["src"]
}

and the <root>/config/tsconfig.browser.json

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "strict": true,
    "allowUnreachableCode": false,
    "outDir": "${configDir}/dist",
    "target": "ESNext",
    "declaration": true,
    "lib": ["ESNext", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "esModuleInterop": true,
    "moduleResolution": "node",
    "verbatimModuleSyntax": true,
    "useDefineForClassFields": false,
    "resolveJsonModule": true,
    "sourceMap": true,
    "declarationMap": true,
    "disableReferencedProjectLoad": true,
    "disableSourceOfProjectReferenceRedirect": false,
    "skipLibCheck": true,
    "composite": true
    // "noImplicitOverride": true
  }
}

emosheeep avatar Mar 24 '25 09:03 emosheeep

Here you are, this is the tsconfig that the problem file belongs to.

{ "extends": "@edenx/tsconfig/base", "compilerOptions": { "declaration": true, "jsx": "preserve", "baseUrl": "./", "paths": { "@/": ["./src/"], "@shared/": ["./shared/"], "@common/": ["./common/"], "@api/": ["./api/"], "@config/": ["./config/"] }, "types": ["react", "react-dom"], "module":"nodenext", "moduleResolution": "nodenext", "experimentalDecorators": true, "emitDecoratorMetadata": true, "strictPropertyInitialization": false, "outDir": "dist", "declarationDir": "dist/types" }, "include": ["src", "shared", "config", "server", "edenx.config.ts", "api"], "exclude": ["**/node_modules", "build"], "references": [ { "path": "../../libs/component" }, { "path": "../../libs/cookieConsent" }, { "path": "../../libs/user" }, { "path": "../../libs/reporter" }, { "path": "../../libs/constants" }, { "path": "../../libs/api" }, { "path": "../../libs/hooks" }, { "path": "../../libs/seo" }, { "path": "../../libs/utils" }, { "path": "../../libs/locale" }, { "path": "../../libs/machine" }, { "path": "../../libs/passport" }, { "path": "../../plugins/infra" }, { "path": "../../packages/global-request-hooks" }, { "path": "../../config" }, { "path": "../../packages/business/common-scss" }, { "path": "../../packages/notify" } ] }

I tested by this, i can't see any issue with that.

rezwanahmedsami avatar Mar 25 '25 22:03 rezwanahmedsami

@emosheeep We (@slackhq) saw this also. I narrowed this down to the fact we had 4 old files leftover after migrations. They had the same name as their new file, but a .js extension instead.

For example:

  • something.js left behind
  • something.ts is the new version
  • something.js resolves to "" in the rootfiles.

Can you confirm this is your case also? Based on your first message, it would mean you have a matching "/Users/emosheep/projects/lvweb-tree/config/src/config/commerce/commerce.js" file

cartond avatar May 29 '25 21:05 cartond

@cartond No, I checked it just now, there isn't a file you said.

Image

emosheeep avatar Jun 04 '25 03:06 emosheeep

It's been a month and there hasn't been a repro provided. We can't really do anything without something to test.

jakebailey avatar Jul 24 '25 20:07 jakebailey