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

Crash in extension development host with "autoAttachChildProcesses": true enabled #873

Closed
segevfiner opened this issue May 26, 2022 · 8 comments
Labels
external-issue issues caused by external system ( (no fix needed) stage: awaiting response

Comments

@segevfiner
Copy link

Environment

  1. vscode-jest version: 4.6.0
  2. node -v: v16.15.0
  3. npm -v or yarn --version: 8.10.0
  4. npm ls jest or npm ls react-scripts (if you haven’t ejected): foobar@0.1.0 /Users/segevfiner/junk/vscode-jest-extension-debug-crash/jest
    └── jest@28.1.0
  5. your vscode-jest settings if customized:
    • jest.jestCommandLine? default
    • jest.autoRun? off
    • anything else that you think might be relevant? N/A
  6. Operating system: macOS 12.4

Prerequisite

  • are you able to run jest test from the command line? yes
  • how do you run your tests from the command line? (for example: npm run test or node_modules/.bin/jest) npx jest

Steps to Reproduce

  1. Clone https://github.com/segevfiner/vscode-jest-extension-debug-crash.
  2. npm install in both the repos root directory and jest subdirectory.
  3. Open in VS Code.
  4. Run the "Run extension" debug configuration
  5. Open the jest subdirectory in the extension development host.
  6. The extension development host exits/crashes a short time after the jest extension activates.

The trigger is "autoAttachChildProcesses": true in the extension's launch configuration.

Relevant Debug Info

Not sure, it crashes, haven't found any log.

Expected Behavior

It doesn't cause a crash.

Actual Behavior

The extension development host crashes.


The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself. If you are interested, feel free to check out the contribution guide, we look forward to seeing your PR...

@connectdotz
Copy link
Collaborator

Not sure what autoAttachChildProcesses is supposed to do as I did not find it in the current vscode doc.

This extension did spawn a child process and I am guessing that is not what you are trying to debug or attach, right?

vscode doc did mention a few ways to attach to the node child process, not knowing what exactly you are trying to debug I am kind of shooting in the dark, but hopefully, their info will be useful to you: https://code.visualstudio.com/docs/nodejs/nodejs-debugging

@segevfiner
Copy link
Author

I'm trying to debug a VS Code extensions, I have created an MWE which is described in the issues description for reproducing this.

Yeah, they don't document the properties of launch configurations that well...

@connectdotz
Copy link
Collaborator

connectdotz commented May 31, 2022

I'm trying to debug a VS Code extensions, I have created an MWE which is described in the issues description for reproducing this.

hmm, I debug our extension all the time without "autoAttachChildProcesses" flag. I did try your use case and yes I can reproduce the crash. But when I turn off the autoAttachChildProcesses flag, I was able to debug your extension just fine, I saw your helloWorld command and was able to set breakpoints etc. What is the reason you think you need this flag?

@segevfiner
Copy link
Author

I have a different extension (proprietary, unreleased ATM) which launches a node child process which this flag allows to seamlessly debug.

@connectdotz
Copy link
Collaborator

connectdotz commented Jun 1, 2022

ok, I dug into this a bit and it seems when you use autoAttachChildProcesses in debug config, vscode will try to attach to every spawned child process, including the ones we spawned for running jest. Seems to me these child processes have quickly exited before vscode can finish debugging setup for them, which then caused vscode internal state error and crashed the debugger process.

There is a feature request in vscode to apply a targeted attach (microsoft/vscode-js-debug#1246) that should address the root cause as I am sure you are not interested in debugging others' child processes. You might need to turn off the vscode-jest extension in your target debuggable workspace (it doesn't need to be your extension's workspace) until vscode addresses the issue.

@connectdotz connectdotz added external-issue issues caused by external system ( (no fix needed) and removed stage: awaiting response labels Jun 1, 2022
@segevfiner
Copy link
Author

Them crashing at all in such a scenario is a bug in and of itself, need to check if that is reported separately to them.

@connectdotz
Copy link
Collaborator

connectdotz commented Jul 9, 2022

@segevfiner does the newly released vscode resolve this issue for you?

@segevfiner
Copy link
Author

Looks like it. I sure hope it does 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-issue issues caused by external system ( (no fix needed) stage: awaiting response
Projects
None yet
Development

No branches or pull requests

2 participants