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

Please don't lock the tsconfig.json file #1032

Closed
supersonicclay opened this issue Dec 4, 2015 · 35 comments
Closed

Please don't lock the tsconfig.json file #1032

supersonicclay opened this issue Dec 4, 2015 · 35 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug typescript Typescript support issues verified Verification succeeded
Milestone

Comments

@supersonicclay
Copy link

I am attempting to use a separate git client and it keeps complaining about the tsconfig.json file being locked. If I close the folder from Visual Studio Code, the file is unlocked but also deleted.

It looks like Visual Studio Code is somehow locking the tsconfig.json file.

Expected:
Allow other applications to read and write the tsconfig.json file even if the folder containing that file is open in Visual Studio Code.

Environment:
Visual Studio Code:
image

OS: Windows 7

@supersonicclay supersonicclay changed the title tsconfig.json file locked Please don't lock the tsconfig.json file Dec 4, 2015
@egamma egamma added the feature-request Request for new features or functionality label Dec 5, 2015
@dbaeumer
Copy link
Member

dbaeumer commented Dec 8, 2015

@claycephas we don't do anything special with the tsconfig.json file and I wasn't able to reproduce this. Can you please use the handle tool from sysinternals (https://technet.microsoft.com/en-us/sysinternals/bb896655.aspx) to see who is locking the file in your case?

@egamma egamma modified the milestone: Backlog Dec 10, 2015
@Clivar
Copy link

Clivar commented Dec 16, 2015

I have the same isue. I dont explicitly open the file but I have a task that modifies it for me. However even if that task is killed I still have to close Visual studio code to unlock the file.
I will use "handle" when it happens again and report back

@tonyeung
Copy link

+1

@Clivar
Copy link

Clivar commented Dec 16, 2015

It happened again... code.exe is locking the file according to handle

@dbaeumer
Copy link
Member

@Clivar do you have any additional steps. I tried various scenarios (having tsconfig.json open, changing it, ....) but I couldn't make code holding a handle to it.

I suspect that the tsserver is holding the handle but before moving it to them I want to make sure that this is the case. When it happens the next time can you provide the command line of the code.exe process holding the lock. That would help ti understand which part of the code is the culprit here since code is multi process and one VSCode instance start ~6 code.exe processes.

@dbaeumer dbaeumer added bug Issue identified by VS Code Team member as probable bug and removed feature-request Request for new features or functionality labels Dec 17, 2015
@tonyeung
Copy link

fwiw, try installing gitex and see if that has to do with anything. The last time I remember it happening was when I checkout/merge branches. Intellisense went crazy and I finally tracked it down to the tsconfig.json being missing. Happened a few more times with the tsconfig.json either being locked or gone all together.

@Clivar
Copy link

Clivar commented Dec 17, 2015

@tonyeung Exactly, I have it when pulling or merging with git. File went missing or was empty sometimes aswell. Happens quite a bit. Closing and reopening code has always fixed the access denied issue so far

@tonyeung
Copy link

@Clivar how do you interact with git (git bash or gitex or sourcetree)?

@Clivar
Copy link

Clivar commented Dec 17, 2015

git bash. I do however commit from inside vs code

@tonyeung
Copy link

@Clivar thanks. So to clarify, you commit within vscode, but do execute other git functions via git bash right?

@supersonicclay
Copy link
Author

I have the same issue of tsconfig.json file is locked and after exiting VS code the tsconfig.json file is deleted.

I use Git Extensions on Windows for all git commands (commit, push, pull).

I had 2 windows open of VS Code and saw that it had an open file handle to the tsconfig.json file. Here's the results from handle and procexp.

C:\Apps>handle tsconfig.json

Handle v4.0
Copyright (C) 1997-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

code.exe           pid: 16764  type: File           260: C:\Source\Modus\client\tsconfig.json
code.exe           pid: 12804  type: File           260: C:\Source\VSS.UI.Utilities\tsconfig.json

PID 12804:

"C:\Program Files (x86)\Microsoft VS Code\Code.exe" "c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\out\utils\electronForkStart" "c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\server\typescript\lib\tsserver.js"

PID 16764:

"C:\Program Files (x86)\Microsoft VS Code\Code.exe" "c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\out\utils\electronForkStart" "c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\server\typescript\lib\tsserver.js"

@Clivar
Copy link

Clivar commented Dec 18, 2015

@tonyeung Exactly, Pull and Push sometimes from UI aswell but most of the time I use GIT Bash for repo actions

@supersonicclay
Copy link
Author

Was able to reproduce the tsconfig.json file lock again. Here's the output to handle.exe:

Handle v4.0
Copyright (C) 1997-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

code.exe pid: 16136 type: File 24C: C:\VSS.UI.Utilities\VSS
.UI.Utilities\tsconfig.json

Process Explorer shows this is the command line for PID 16136:

"C:\Program Files (x86)\Microsoft VS Code\code.exe" "c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\out\utils\electronForkStart" "c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\server\typescript\lib\tsserver.js"

After exiting Visual Studio Code the tsconfig.json file was deleted.

@tonyeung
Copy link

I think the deletion of the tsconfig.json file makes this a pretty critical bug.

The first time it happened it took me a while to figure out what happened. The worse part is that the built in git client didn't pick up the change for a while, so I didn't notice anything missing. If for some reason someone was working without source control it would be a nightmare to figure out why intellisense doesn't work anymore.

@glen-84
Copy link

glen-84 commented Jan 1, 2016

I've seen the same thing with other files (it was a TypeScript file this time):

$ git rebase upstream/master
First, rewinding head to replay your work on top of it...
error: unable to create file gulp-typescript/gulp-typescript.d.ts (Permission denied)
Fast-forwarded master to upstream/master.

$ git rebase upstream/master
gulp-typescript/gulp-typescript.d.ts: Permission denied
Current branch master is up to date.

$ git rebase upstream/master
Cannot rebase: You have unstaged changes.
Please commit or stash them.

$ git status
On branch master
Your branch is ahead of 'origin/master' by 627 commits.
  (use "git push" to publish your local commits)
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        deleted:    gulp-typescript/gulp-typescript.d.ts

no changes added to commit (use "git add" and/or "git commit -a")

The file was open inside VS Code.

Windows 10.

Edit: This might actually be #901.

@dbaeumer
Copy link
Member

dbaeumer commented Jan 4, 2016

@claycephas Thanks a lot for the information. As suspected it is the tsserver that locks the tsconfig.json file. I will open a bug against the TypeScript team. I have one additional question: are you seeing this with the latest VSCode as well (e.g. 0.10.6). This version ships with a new version of the tsserver.

@dbaeumer
Copy link
Member

dbaeumer commented Jan 4, 2016

Open microsoft/TypeScript#6337 in TS land

@dbaeumer dbaeumer added the typescript Typescript support issues label Jan 4, 2016
@tonyeung
Copy link

tonyeung commented Jan 4, 2016

@dbaeumer i just had an issue with the tsconfig.json file again last night.. or was it early this morning.. I'm pretty sure I'm on the latest vs code.

@joe-herman
Copy link

I'm having a weird problem with tsconfig.json when VSCode is open. If I do a git checkout someBranch tsconfig.json sometimes gets deleted or locked and I have to issue a git reset --hard HEAD despite having just switched branches. tsconfig.json exists in both branches.

All git commands are issued by commandline (ie: not through VSCode).

I think this is caused by VSCode locking the tsconfig file so git can't overwrite it or something, and it eventually ends up deleted. If VSCode is closed, this doesn't happen. However, no git errors ever occur and I don't notice until my tsc commands fail or I do a git status. Pretty fishy.

VSCode 0.10.6, git v2.5.1-windows.1

@tonyeung
Copy link

tonyeung commented Jan 5, 2016

@Penryn its an issue with tsserver, @dbaeumer already opened a ticket with the typescript team.

@joe-herman
Copy link

Ah, thank you for the update. I understand now.

@pocesar
Copy link

pocesar commented Jan 18, 2016

vscode keeps deleting my tsconfig.json whenever I checkout a new git branch

@dbaeumer
Copy link
Member

@pocesar: could it be that git deletes it. We don't have any logic in regards to git operations. (e.g. what happens if you checkout the branch without having VSCode open)

@pocesar
Copy link

pocesar commented Jan 20, 2016

@dbaeumer nope, tsconfig.json is on all of my branches. when vscode is closed, the tsconfig.json is kept intact, when vscode is open, I always need need to reset it

@dbaeumer
Copy link
Member

@pocesar: is your repository public so that I can try to reproduce.

@supersonicclay
Copy link
Author

Another repro with VS Code version 0.10.6.

image

Output from handle.exe:

C:\Users\canders2>c:\apps\Handle.exe tsconfig.json

Handle v4.0
Copyright (C) 1997-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

code.exe           pid: 1520   type: File           260: C:\Source\Modus\client\tsconfig.json

Output from procexp.exe

Path:
C:\Program Files (x86)\Microsoft VS Code\code.exe

Command line:
"C:\Program Files (x86)\Microsoft VS Code\Code.exe" "c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\out\utils\electronForkStart" "c:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\typescript\server\typescript\lib\tsserver.js"

Current Directory:
C:\Program Files (x86)\Microsoft VS Code\

PARENT:
PID 15536

PARENT Path:
C:\Program Files (x86)\Microsoft VS Code\code.exe

PARENT Command line:
"C:\Program Files (x86)\Microsoft VS Code\Code.exe" "c:\Program Files (x86)\Microsoft VS Code\resources\app\out\bootstrap" --type=pluginHost

PARENT Current directory:
C:\Program Files (x86)\Microsoft VS Code\

After killing PID 1520: client\tsconfig.json file is deleted.
image

@dbaeumer
Copy link
Member

@claycephas did you run a git operation when that happened (e.g. switching branches). I think the deletion of the tsconfig.json file happens as follows:

  • some one tries to delete tsconfig.json. However since it is locked it fails, however to my knowledge Windows queues the delete and executes it when the lock is gone.
  • when VSCode ends the file will be deleted.

@pocesar
Copy link

pocesar commented Jan 24, 2016

@dbaeumer it's private, but like was demonstrated by other people in here, it's fairly easy to reproduce. I opened the Devtools inside vscode, and caught this error

vscode

intellisense for Typescript stops completely, even though my build task is running

@supersonicclay
Copy link
Author

@dbaeumer, the command I was running was git checkout to switch branches.

@bpasero
Copy link
Member

bpasero commented Jan 28, 2016

@dbaeumer I can reproduce on Windows 10. Here are some things I see that are weird:

  • it reproduces only once I open a TS file, so I speculate TS-Server locks the file
  • it does not reproduce in 0.10.7-dev
  • it does also not reproduce for me when I run 0.10.6 "out of dev"

I am puzzled what kind of difference it could make to run 0.10.6 built or "out of dev" with regards to file locking.

@dbaeumer
Copy link
Member

As puzzles as I am :-). As said today I was not able to reproduce this in the upcoming 0.10.7-dev build with the identical tsserver bits. When testing under 0.10.6 I noticed that the first file the tsserver reads get locked. But I have no explanation for it.

@bpasero you mentioned today that you disabled asar support. Could it be that asar support is still on in 0.10.6 when using code.exe as a node environment and in 0.10.7 it is off. That could be an explanation for the behavior.

@bpasero
Copy link
Member

bpasero commented Jan 29, 2016

@dbaeumer I reverted my change for noasar and it did not make a difference. Unfortunately I am not able to easily switch back to the Electron we shipped in 0.10.6 because of all the API changes in Electron that I adopted, otherwise we could nail this down more easily.

Btw I also once commented out all file watching code in TS-Server and could still reproduce the file locking issue, so it seems to be unrelated.

@dbaeumer
Copy link
Member

@bpasero yes, it is unrelated to file watching. I was able to reproduce on 0.10.6 with a simple fs.readFileSync but not on 0.10.7.

@dbaeumer dbaeumer modified the milestones: Jan 2016, Backlog Jan 29, 2016
@dbaeumer dbaeumer assigned bpasero and unassigned dbaeumer Jan 29, 2016
@dbaeumer
Copy link
Member

I will close this as fixed for 0.10.7 since all test cases we have that fail on 0.10.6 pass on 0.10.7 although we don't have the final answer why.

@bpasero can you please marked as verified.

@bpasero bpasero added the verified Verification succeeded label Jan 29, 2016
@pke
Copy link

pke commented Oct 21, 2016

This problem is in all Electron based editors. Atom has the same probs. So the real problem lays in the way Electron (Nodejs?) opens files on Windows. It should open them with no lock of course.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug typescript Typescript support issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

10 participants