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

TSServer holds file locks on build output, preventing 'clean' #29064

Closed
MLoughry opened this issue Dec 17, 2018 · 9 comments
Closed

TSServer holds file locks on build output, preventing 'clean' #29064

MLoughry opened this issue Dec 17, 2018 · 9 comments
Assignees
Labels
Duplicate An existing issue was already created

Comments

@MLoughry
Copy link

TypeScript Version: 3.2.1

Search Terms:
tsserver, file lock, delete, clean, rimraf

Code

No code.

When running TSServer (as part of VSCode) with project references and an outDir specified (such that downstream project references reference the .d.ts files in the outDir), TSServer will sometimes hold locks on files, preventing build processes from "cleaning" the outDir, such as by using rimraf

Expected behavior:
Cleaning happens without error

Actual behavior:
Error: EPERM: operation not permitted, unlink 'D:\vso\client-web\obj\datetime\packages', for example, though any of various EPREM errors can occur. Closing VSCode or instructing it to restart the TSServer always resolves the issue.

@sheetalkamat
Copy link
Member

@MLoughry Can you provide tsserver log from such session, I have observed directory watchers to be cause of such holds as compared to file watching so repro and log would be helpful to see what we can do here. Thanks

@sheetalkamat sheetalkamat added the Needs More Info The issue still hasn't been fully clarified label Dec 17, 2018
@MLoughry
Copy link
Author

It's not a 100% repro, so of course it's being difficult now. 😔 I'll try to get you a log.

@MLoughry
Copy link
Author

MLoughry commented Jan 8, 2019

@sheetalkamat, I managed to catch a repro, and posted the logs to https://github.com/MLoughry/typescript-29064

From tsserver.log, the lines surrounding the time repo in build.log:

Info 35900[10:37:50.875] Starting updateGraphWorker: Project: d:/vso/client-web/obj/common/controls/tsconfig.json
Info 35901[10:38:12.762] DirectoryWatcher:: Added:: WatchInfo: d:/vso/client-web/obj/common/controls/packages 1 Project: d:/vso/client-web/obj/common/controls/tsconfig.json WatchType: Directory of Failed lookup locations in module resolution

build.log

[10:38:08] Using gulpfile D:\vso\client-web\gulpfile.js
[10:38:08] Starting 'build'...
[10:38:08] Starting 'determineEntrypoints'...
[10:38:08] Finished 'determineEntrypoints' after 7.55 ms
[10:38:08] Starting 'build:setup'...
[10:38:08] Starting 'build:clean'...
[10:38:08] Starting 'cop:tsconfig'...
[10:38:09] Finished 'cop:tsconfig' after 582 ms
[10:38:40] 'build:clean' errored after 32 s
[10:38:40] Error in plugin "clean"
Message:
  "errno": -4048,
  "code": "EPERM",
  "syscall": "unlink",
  "path": "D:\\vso\\client-web\\obj\\datetime",
  "stack": "Error: EPERM: operation not permitted, unlink 'D:\\vso\\client-web\\obj\\datetime'",
  "message": "EPERM: operation not permitted, unlink 'D:\\vso\\client-web\\obj\\datetime'",
  "name": "Error"
}
Details:
    domain: [object Object]
    domainThrown: true

@MLoughry
Copy link
Author

Pinging @sheetalkamat

Even if this is not currently prioritized, can the Needs more info tag be removed, since info has been provided?

@sheetalkamat sheetalkamat removed the Needs More Info The issue still hasn't been fully clarified label Jan 29, 2019
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Feb 5, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.5.0 milestone Feb 5, 2019
@apantea01
Copy link

Experiencing the same issue

@apantea01
Copy link

Is there another workaround besides restarting VS Code?

@MLoughry
Copy link
Author

Restarting just the TS Server usually fixes the issue as well.

image

@ljcrapo
Copy link

ljcrapo commented Feb 22, 2019

Same issue when trying to run npm ci while vscode is running.

npm WARN prepare removing existing node_modules/ before installation
npm ERR! path <project dir>\node_modules\@types
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink '<project dir>\node_modules\@types'
npm ERR!  { Error: EPERM: operation not permitted, unlink '<project dir>\node_modules\@types'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink '<project dir>\node_modules\@types'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path: '<project dir>\\node_modules\\@types' },
npm ERR!   isOperational: true,
npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink \'<project dir>\\node_modules\\@types\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: '<project dir>\\node_modules\\@types' }

it seems the TSService has a lock on the @types folder
OS
Windows

tsc -v
3.2.1

npm -v
6.7.0

@sheetalkamat
Copy link
Member

This is duplicate of #29407 and marking as such

@sheetalkamat sheetalkamat added Duplicate An existing issue was already created and removed Needs Investigation This issue needs a team member to investigate its status. labels Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants