Skip to content
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

[Bug?]: TypeScript language server fails in vscode due to "No file descriptors available" (zipfs) #5172

Closed
1 task
noahnu opened this issue Jan 3, 2023 · 0 comments · Fixed by #5178
Closed
1 task
Labels
bug Something isn't working

Comments

@noahnu
Copy link
Contributor

noahnu commented Jan 3, 2023

Self-service

  • I'd be willing to implement a fix

Describe the bug

Using Yarn 3.3.1 (pnp), TypeScript 4.9.4, and VSCode 1.74.2 (Universal), the TSServer will occasionally crash with "Libzip Error: Can't open file: No file descriptors available".

    Can't open file: No file descriptors available

    Libzip Error: Can't open file: No file descriptors available
        at ZipFS.makeLibzipError (/Users/noah/dev/project/.pnp.cjs:39578:25)
        at new ZipFS (/Users/noah/dev/project/.pnp.cjs:39553:20)
        at ZipOpenFS.getZipSync (/Users/noah/dev/project/.pnp.cjs:41739:18)
        at ZipOpenFS.makeCallSync (/Users/noah/dev/project/.pnp.cjs:41619:17)
        at ZipOpenFS.watchFile (/Users/noah/dev/project/.pnp.cjs:41582:17)
        at VirtualFS.watchFile (/Users/noah/dev/project/.pnp.cjs:40788:24)
        at PosixFS.watchFile (/Users/noah/dev/project/.pnp.cjs:40788:24)
        at NodePathFS.watchFile (/Users/noah/dev/project/.pnp.cjs:40788:24)
        at fsWatchFileWorker (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:7326:21)
        at /Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6897:133
        at createSingleWatcherPerName (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6447:26)
        at pollingWatchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6897:20)
        at watchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6778:28)
        at watchMissingFileSystemEntry (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:7006:24)
        at fsWatchHandlingExistenceOnHost (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6911:17)
        at /Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6900:168
        at createSingleWatcherPerName (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6447:26)
        at fsWatch (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6900:20)
        at Object.watchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6784:28)
        at watchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:118449:90)
        at Object.watchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:118519:115)
        at createFileWatcherWithLogging (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:118492:50)
        at Object.watchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:118475:34)
        at Project.watchAffectingFileLocation (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:173896:57)
        at createFileWatcherOfAffectingLocation (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:124669:32)
        at watchAffectingLocationsOfResolution (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:124638:17)
        at watchFailedLookupLocationOfResolution (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:124626:13)
        at Array.forEach (<anonymous>)
        at watchFailedLookupLocationOfNonRelativeModuleResolutions (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:124702:29)
        at Map.forEach (<anonymous>)
        at Object.finishCachingPerDirectoryResolution (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:124285:50)
        at Project.updateGraphWorker (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:174443:38)
        at Project.updateGraph (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:174368:42)
        at ConfiguredProject.updateGraph (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:175534:63)
        at ProjectService.createLoadAndUpdateConfiguredProject (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:177302:25)
        at ProjectService.assignProjectToOpenedScriptInfo (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:178389:44)
        at /Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:178729:97
        at Object.flatMap (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:524:25)
        at ProjectService.applyChangesInOpenFiles (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:178729:41)
        at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:180122:46)
        at /Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:182315:96
        at Session.executeWithRequestId (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:182306:28)
        at Session.executeCommand (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:182315:41)
        at Session.onMessage (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:182343:35)
        at IpcIOSession.onMessage (/Users/noah/dev/project/.yarn/sdks/typescript/lib/tsserver.js:199:32)
        at process.<anonymous> (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:186509:31)
        at process.emit (node:events:526:28)
        at process.emit (/Users/noah/dev/project/.pnp.cjs:46881:25)
        at emit (node:internal/child_process:938:14)
        at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
Info 4870 [16:38:55.845] response:
    {"seq":0,"type":"response","command":"updateOpen","request_seq":2,"success":false,"message":"Error processing request. Can't open file: No file descriptors available\nLibzip Error: Can't open file: No file descriptors available\n    at ZipFS.makeLibzipError (/Users/noah/dev/project/.pnp.cjs:39578:25)\n    at new ZipFS (/Users/noah/dev/project/.pnp.cjs:39553:20)\n    at ZipOpenFS.getZipSync (/Users/noah/dev/project/.pnp.cjs:41739:18)\n    at ZipOpenFS.makeCallSync (/Users/noah/dev/project/.pnp.cjs:41619:17)\n    at ZipOpenFS.watchFile (/Users/noah/dev/project/.pnp.cjs:41582:17)\n    at VirtualFS.watchFile (/Users/noah/dev/project/.pnp.cjs:40788:24)\n    at PosixFS.watchFile (/Users/noah/dev/project/.pnp.cjs:40788:24)\n    at NodePathFS.watchFile (/Users/noah/dev/project/.pnp.cjs:40788:24)\n    at fsWatchFileWorker (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:7326:21)\n    at /Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6897:133\n    at createSingleWatcherPerName (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6447:26)\n    at pollingWatchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6897:20)\n    at watchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6778:28)\n    at watchMissingFileSystemEntry (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:7006:24)\n    at fsWatchHandlingExistenceOnHost (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6911:17)\n    at /Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6900:168\n    at createSingleWatcherPerName (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6447:26)\n    at fsWatch (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6900:20)\n    at Object.watchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:6784:28)\n    at watchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:118449:90)\n    at Object.watchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:118519:115)\n    at createFileWatcherWithLogging (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:118492:50)\n    at Object.watchFile (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:118475:34)\n    at Project.watchAffectingFileLocation (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:173896:57)\n    at createFileWatcherOfAffectingLocation (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:124669:32)\n    at watchAffectingLocationsOfResolution (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:124638:17)\n    at watchFailedLookupLocationOfResolution (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:124626:13)\n    at Array.forEach (<anonymous>)\n    at watchFailedLookupLocationOfNonRelativeModuleResolutions (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:124702:29)\n    at Map.forEach (<anonymous>)\n    at Object.finishCachingPerDirectoryResolution (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:124285:50)\n    at Project.updateGraphWorker (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:174443:38)\n    at Project.updateGraph (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:174368:42)\n    at ConfiguredProject.updateGraph (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:175534:63)\n    at ProjectService.createLoadAndUpdateConfiguredProject (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:177302:25)\n    at ProjectService.assignProjectToOpenedScriptInfo (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:178389:44)\n    at /Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:178729:97\n    at Object.flatMap (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:524:25)\n    at ProjectService.applyChangesInOpenFiles (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:178729:41)\n    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:180122:46)\n    at /Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:182315:96\n    at Session.executeWithRequestId (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:182306:28)\n    at Session.executeCommand (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:182315:41)\n    at Session.onMessage (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:182343:35)\n    at IpcIOSession.onMessage (/Users/noah/dev/project/.yarn/sdks/typescript/lib/tsserver.js:199:32)\n    at process.<anonymous> (/Users/noah/.yarn/berry/cache/typescript-patch-7bc527fc0a-8.zip/node_modules/typescript/lib/tsserver.js:186509:31)\n    at process.emit (node:events:526:28)\n    at process.emit (/Users/noah/dev/project/.pnp.cjs:46881:25)\n    at emit (node:internal/child_process:938:14)\n    at process.processTicksAndRejections (node:internal/process/task_queues:84:21)"}

From playing around in my private project, it seems to be related to the number of files? Deleting a number of files (doesn't matter which ones) seems to ensure the TSServer starts up successfully. When I add back the files and reload VSCode, the TSServer gets stuck in a restart loop and gives up after 5 attempts.

I'm only experiencing this issue with TS 4.9.3 and 4.9.4. Downgrading to 4.8.4 works.

When I don't delete any files, I actually get "Cannot find module" for all npm modules, though the server doesn't appear to have failed. Looking at the logs, I see:

Info 4700 [16:52:04.779] DirectoryWatcher:: Added:: WatchInfo: /Users/noah/.yarn/berry/cache/gsap-npm-3.10.4-f56e6163df-8.zip/node_modules 1 undefined Project: /Users/noah/dev/project/tsconfig.json WatchType: Failed Lookup Locations
Info 4701 [16:52:04.779] Exception when creating directory watcher: Can't open file: No file descriptors available

which seems related to the above error.

As a workaround, using the old polling mechanism in vscode seems to work:

    "typescript.tsserver.watchOptions": {
        "watchFile": "fixedPollingInterval",
        "watchDirectory": "fixedPollingInterval"
    }

(the default watcher changed in 4.9: microsoft/TypeScript@10a7b4e)

To reproduce

Happens on a large project. Haven't been able to reproduce in a dedicated repo yet.

Environment

System:
    OS: macOS 12.6.2
    CPU: (8) arm64 Apple M1 Pro
  Binaries:
    Node: 16.18.1 - /private/var/folders/5m/4x2x5y6x5x5ck7rnpzq23dlc0000gn/T/xfs-111d8dba/node
    Yarn: 3.3.1 - /private/var/folders/5m/4x2x5y6x5x5ck7rnpzq23dlc0000gn/T/xfs-111d8dba/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.1/bin/npm

  VSCode:
    Version: 1.74.2 (Universal)
    Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161
    Date: 2022-12-20T10:26:09.430Z
    Electron: 19.1.8
    Chromium: 102.0.5005.167
    Node.js: 16.14.2
    V8: 10.2.154.15-electron.0
    OS: Darwin arm64 21.6.0
    Sandboxed: No

My tsconfig.json:

{
    "compilerOptions": {
        "target": "ESNext",
        "noImplicitAny": true,
        "moduleResolution": "node",
        "allowJs": true,
        "noEmit": true,
        "strict": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "experimentalDecorators": true,
        "downlevelIteration": true,
        "skipLibCheck": true,
        "jsx": "preserve",
        "lib": [
            "esnext",
            "dom",
            "dom.iterable"
        ],
        "resolveJsonModule": true,
        "noErrorTruncation": true
    },
    "include": [
        "src",
        "typings",
    ],
    "exclude": [
        "**/node_modules/*",
    ],
}

Additional context

Possibly related: #4488

@noahnu noahnu added the bug Something isn't working label Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant