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

Insiders failed to launch for test run using vscode-test ("Could not delete obsolete instance handle" - sock file missing?) #86382

Closed
DanTup opened this issue Dec 5, 2019 · 27 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@DanTup
Copy link
Contributor

DanTup commented Dec 5, 2019

I don't have repro steps for this (nor do I know how common it is), but it seems like this came up in #81652 but the issue was closed by the bot and it doesn't seem like it was addressed.

I'm running tests on GitHub Actions - this one using macOS. I use vscode-test to run the tests like this:

const res = await vstest.runTests({
	extensionDevelopmentPath: cwd,
	extensionTestsEnv: { ...testEnv, ...env },
	extensionTestsPath: path.join(cwd, "out", "src", "test", testFolder),
	launchArgs: [
		path.isAbsolute(workspaceFolder)
			? workspaceFolder
			: path.join(cwd, "src", "test", "test_projects", workspaceFolder),
		"--user-data-dir",
		path.join(cwd, ".dart_code_test_data_dir"),
	],
	version: process.env.CODE_VERSION,
});

This is called multiple times with different testFolder and workspaceFolder params. One test run was fine, but then I got this error (which then repeated for every subsequent invocation in the same way):

2019-12-05T09:17:37.8141490Z �[0m  test environment�[0m
2019-12-05T09:17:37.8146740Z 
2019-12-05T09:17:37.8147990Z   �[32m  ✓�[0m�[90m has opened the correct folder�[0m
2019-12-05T09:17:37.8150710Z 
2019-12-05T09:17:37.8151900Z �[92m �[0m�[32m 3 passing�[0m�[90m (6s)�[0m
2019-12-05T09:17:37.8152370Z 
2019-12-05T09:17:37.8158840Z Test run is complete! Calling VS Code callback with (null, 0)
2019-12-05T09:17:37.8173710Z 
2019-12-05T09:17:40.8880150Z Exit code:   0
2019-12-05T09:17:40.8880790Z Done
2019-12-05T09:17:40.8881040Z 
2019-12-05T09:17:40.8881520Z ############################################################
2019-12-05T09:17:40.8881740Z 
2019-12-05T09:17:40.8881870Z 
2019-12-05T09:17:40.8882050Z 
2019-12-05T09:17:40.8882550Z Running not_activated/dart_create tests folder in workspace empty
2019-12-05T09:17:40.8884650Z Attempting to download VS Code attempt #1
2019-12-05T09:17:41.1385550Z Found .vscode-test/vscode-1.40.2. Skipping download.
2019-12-05T09:17:41.1386330Z Running tests with pre-downloaded VS Code
2019-12-05T09:17:41.6285570Z Found .vscode-test/vscode-insiders matching latest Insiders release. Skipping download.
2019-12-05T09:17:42.0750980Z �[93m[main 2019-12-05T09:17:42.070Z]�[0m Could not delete obsolete instance handle Error: ENOENT: no such file or directory, unlink '/Users/runner/runners/2.162.0/work/Dart-Code/Dart-Code/.dart_code_test_data_dir/1.41.0-insider-main.sock'
2019-12-05T09:17:42.0751790Z     at Object.unlinkSync (original-fs.js:976:3)
2019-12-05T09:17:42.0752680Z     at Object.doStartup (/Users/runner/runners/2.162.0/work/Dart-Code/Dart-Code/.vscode-test/vscode-insiders/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/code/electron-main/main.js:551:165)
2019-12-05T09:17:42.0752980Z     at processTicksAndRejections (internal/process/task_queues.js:89:5) {
2019-12-05T09:17:42.0753490Z   errno: -2,
2019-12-05T09:17:42.0754000Z   syscall: 'unlink',
2019-12-05T09:17:42.0754680Z   code: 'ENOENT',
2019-12-05T09:17:42.0755420Z   path: '/Users/runner/runners/2.162.0/work/Dart-Code/Dart-Code/.dart_code_test_data_dir/1.41.0-insider-main.sock'
2019-12-05T09:17:42.0755680Z }
2019-12-05T09:17:42.0755760Z 
2019-12-05T09:17:42.0757390Z �[91m[main 2019-12-05T09:17:42.075Z]�[0m Error: ENOENT: no such file or directory, unlink '/Users/runner/runners/2.162.0/work/Dart-Code/Dart-Code/.dart_code_test_data_dir/1.41.0-insider-main.sock'
2019-12-05T09:17:42.0758040Z     at Object.unlinkSync (original-fs.js:976:3)
2019-12-05T09:17:42.0758900Z     at Object.doStartup (/Users/runner/runners/2.162.0/work/Dart-Code/Dart-Code/.vscode-test/vscode-insiders/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/code/electron-main/main.js:551:165)
2019-12-05T09:17:42.0759230Z     at processTicksAndRejections (internal/process/task_queues.js:89:5)
2019-12-05T09:17:42.0759320Z 
2019-12-05T09:17:42.0884930Z Exit code:   1
2019-12-05T09:17:42.0886770Z Done
2019-12-05T09:17:42.0886940Z 
2019-12-05T09:17:42.0894300Z Failed
2019-12-05T09:17:42.0894790Z ############################################################
2019-12-05T09:17:42.0918950Z 

Is this something VS Code can recover better from? It's particularly bad on GitHub Actions where it's not possible to re-run individual steps (so I have to re-run a whole 1-hour run to retry this) - though I appreciate that's hardly VS Code's fault :-)

@DanTup
Copy link
Contributor Author

DanTup commented Dec 5, 2019

Actually, I'm seeing this reliably. Most of my bots only run one set of tests, but the one that runs multiple is seeing this on Insiders on macOS all the time.

Anything I can do to get more info that might help understand what's happening?

@octref
Copy link
Contributor

octref commented Dec 5, 2019

@dbaeumer I see some old issues where you know more about the socket files created. Do you have any pointers why this might happen?

@octref octref self-assigned this Dec 5, 2019
@octref octref added extensions-development Issues for developing extensions bug Issue identified by VS Code Team member as probable bug labels Dec 5, 2019
@octref octref added this to the Backlog milestone Dec 5, 2019
@dbaeumer
Copy link
Member

dbaeumer commented Dec 6, 2019

@octref for communication between various processes we use socket files under Linux / MacOS. The one mentioned here is for the main process. May be @bpasero knows about it.

I was on issues for the extension host and LSP server.

The problem looks like someone tries to delete a non existing socket file (ENOENT). May be we are simply missing code to handle this correctly

@bpasero
Copy link
Member

bpasero commented Dec 6, 2019

I can answer if I know the source process and the target process. We have different IPC mechanisms in place depending on that.

@octref
Copy link
Contributor

octref commented Dec 11, 2019

@DonJayamanne Did the problem in #81652 go away or did you find a solution?

@DonJayamanne
Copy link
Contributor

Unfortunately this didn't go away for me.

@octref
Copy link
Contributor

octref commented Dec 12, 2019

I don't think this is specific to vscode-test, but launching VS Code in general. @joaomoreno you are assigned for the other issue as well, do you have any insights?

@octref octref assigned joaomoreno and bpasero and unassigned octref Dec 12, 2019
@octref octref removed the extensions-development Issues for developing extensions label Dec 12, 2019
@bpasero bpasero removed their assignment Dec 13, 2019
@bpasero bpasero added the ipc label Dec 13, 2019
@bpasero bpasero removed this from the Backlog milestone Dec 13, 2019
@bpasero
Copy link
Member

bpasero commented Dec 13, 2019

@DonJayamanne @DanTup would be good if you can try to reproduce this running out of sources, then we can possibly add some logging code

@DanTup
Copy link
Contributor Author

DanTup commented Jan 3, 2020

@joaomoreno
Copy link
Member

joaomoreno commented Jan 15, 2020

This comes from

logService.warn('Could not delete obsolete instance handle', error);

Which means that Code (1) wasn't able to connect to an existing socket file and (2) wasn't able to delete the socket file. So it can't proceed. Deleting the socket file is the recover action. If that fails we can't do anything else.

Do these tests run concurrently? If so, you must prevent that and run them serially, or run them all with separate user data dirs.

@joaomoreno joaomoreno added info-needed Issue requires more information from poster and removed bug Issue identified by VS Code Team member as probable bug ipc labels Jan 15, 2020
@DanTup
Copy link
Contributor Author

DanTup commented Jan 15, 2020

@joaomoreno they do not run currently. I included a link to the code that runs the tests:

https://github.com/DanTup/vscode-sock-issue-86382/blob/1b26fc751d575aa81103da1d5b79eacd84f7a862/src/test/test_all.ts#L33

runTests is a function defined just above those lines, which just calls runTests of vscode-test and awaits it.

@joaomoreno
Copy link
Member

Does it work if you sleep between runTests?

@DanTup
Copy link
Contributor Author

DanTup commented Jan 16, 2020

It doesn't appear to. I added:

await new Promise((resolve) => setTimeout(resolve, 5000));

And still have the same failure:

https://github.com/DanTup/vscode-sock-issue-86382/runs/393328115#step:7:54

@joaomoreno
Copy link
Member

Can you check whether that directory exists at the time the error occurs?

/Users/runner/runners/2.163.1/work/vscode-sock-issue-86382/vscode-sock-issue-86382/.test_data_dir

@DanTup
Copy link
Contributor Author

DanTup commented Jan 16, 2020

That's the folder passed to VS Code's --user-data-dir flag so it will be created by the first test run (as far as I know, VS Code does not delete it).

If you fork the repo, it should all be set up to run using GitHub Actions when you commit, so it may be easier for you to debug there directly.

@joaomoreno
Copy link
Member

joaomoreno commented Jan 17, 2020

Unfortunately I cannot afford to spend a day investigating an obscure user CI issue, surely you can understand. I'm more than happy to give you a general direction on where to look.

In any case, I would still write some code that checks for that folder's existence once runTests throws.

@vscodebot vscodebot bot closed this as completed Jan 28, 2020
@vscodebot
Copy link

vscodebot bot commented Jan 28, 2020

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@connor4312
Copy link
Member

Rob mentioned he's running into this when running from js-debug, see the linked issue for details. I postulated it might be related to our forceful killTree function that causes some bad/missing teardown behavior in VS Code.

@roblourens
Copy link
Member

roblourens commented Mar 3, 2020

For me this is easy to repro. I can investigate more if someone can point me towards where these socket files are created and if you know why their path lengths might be limited. Seems like the path length is limited to 103 characters.

mkdir -p /tmp/aaaaaaaa/bbbbbbbbbbbbb/cccccccccccccccc/dddddddddddddddd/eeeeeeeeeeeeeee/fffffffffffffffff/gggggggggggggggggg/hhhhhhhhhhhhhhhhh/iiiiiiiiiiiiiii
code-insiders --user-data-dir /tmp/aaaaaaaa/bbbbbbbbbbbbb/cccccccccccccccc/dddddddddddddddd/eeeeeeeeeeeeeee/fffffffffffffffff/gggggggggggggggggg/hhhhhhhhhhhhhhhhh/iiiiiiiiiiiiiii # works
# same command again with --verbose, produces the error

ls -l /tmp/aaaaaaaa/bbbbbbbbbbbbb/cccccccccccccccc/dddddddddddddddd/eeeeeeeeeeeeeee/fffffffffffffffff/ggggggg

srwxr-xr-x  1 roblou  wheel  0 Mar  2 20:40 /tmp/aaaaaaaa/bbbbbbbbbbbbb/cccccccccccccccc/dddddddddddddddd/eeeeeeeeeeeeeee/fffffffffffffffff/ggggggg

@roblourens
Copy link
Member

@roblourens
Copy link
Member

Here is my suggested fix #91931

@roblourens roblourens reopened this Mar 3, 2020
@roblourens roblourens self-assigned this Mar 3, 2020
roblourens added a commit that referenced this issue Mar 3, 2020
@roblourens roblourens added bug Issue identified by VS Code Team member as probable bug ipc and removed info-needed Issue requires more information from poster labels Mar 4, 2020
@joaomoreno
Copy link
Member

Added comment to the PR: #91931 (review)

Given that this is one instance and it's even a CI and not an actual use case, please just use a shorter user data dir. Is that possible?

@roblourens
Copy link
Member

Will do this instead

How about I check the length and log a warning if it's too long but leave the logic alone

@roblourens roblourens added this to the April 2020 milestone Apr 6, 2020
joaomoreno added a commit that referenced this issue Apr 8, 2020
Add warning about long generated IPC paths, fix #86382
@connor4312 connor4312 added the verified Verification succeeded label Apr 29, 2020
badsyntax added a commit to badsyntax/vscode-spotless-gradle that referenced this issue May 18, 2020
Needs to be in short dir name, see microsoft/vscode#86382
badsyntax added a commit to badsyntax/vscode-spotless-gradle that referenced this issue May 18, 2020
Needs to be in short dir name, see microsoft/vscode#86382
badsyntax added a commit to badsyntax/vscode-spotless-gradle that referenced this issue May 18, 2020
Needs to be in short dir name, see microsoft/vscode#86382
badsyntax added a commit to microsoft/vscode-gradle that referenced this issue May 18, 2020
valentjn added a commit to valentjn/vscode-ltex that referenced this issue May 20, 2020
This fixes the following error:

WARNING: IPC handle [...] is longer than 103 chars, try a shorter
--user-data-dir
Could not delete obsolete instance handle Error: ENOENT:
no such file or directory

This is a workaround for
microsoft/vscode#86382.
When using a long path for --user-data-dir, on OSX VS Code could
only be started once. Restarting VS Code would result in the
error given above.
valentjn added a commit to valentjn/vscode-ltex that referenced this issue May 21, 2020
This fixes the following error:

WARNING: IPC handle [...] is longer than 103 chars, try a shorter
--user-data-dir
Could not delete obsolete instance handle Error: ENOENT:
no such file or directory

This is a workaround for
microsoft/vscode#86382.
When using a long path for --user-data-dir, on OSX VS Code could
only be started once. Restarting VS Code would result in the
error given above.
valentjn added a commit to valentjn/vscode-ltex that referenced this issue May 24, 2020
This fixes the following error:

WARNING: IPC handle [...] is longer than 103 chars, try a shorter
--user-data-dir
Could not delete obsolete instance handle Error: ENOENT:
no such file or directory

This is a workaround for
microsoft/vscode#86382.
When using a long path for --user-data-dir, on OSX VS Code could
only be started once. Restarting VS Code would result in the
error given above.
@github-actions github-actions bot locked and limited conversation to collaborators May 27, 2020
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 verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants