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

Creating a worker thread in the extension host crashes VS Code #88386

Closed
connor4312 opened this issue Jan 9, 2020 · 9 comments
Closed

Creating a worker thread in the extension host crashes VS Code #88386

connor4312 opened this issue Jan 9, 2020 · 9 comments
Assignees
Labels
electron Issues and items related to Electron info-needed Issue requires more information from poster upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Milestone

Comments

@connor4312
Copy link
Member

connor4312 commented Jan 9, 2020

The worker_thread API is available, but attempting to use it in an extension crashes VS Code.

  1. Create a "hello world" extension from a template
  2. Create a blank worker.js file
  3. Add this to your extension's activate:
const { Worker } = require('worker_threads');
new Worker(join(__dirname, 'worker.js'));
  1. Run the extension. VS Code crashes upon activation.
connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Jan 9, 2020
I noticed in profiles that this was actually a bottleneck for Jest tests
(in #214) when running as a cluster. I wanted to use a worker thread
for it, but it looks like there's an issue in vscode preventing that[1]
for the moment.

This cuts the time-to-first-breakpoint in half for the jest tests, which
is fairly nice. The child process is killed after 30 seconds of
inactivity. I may do an algorithmic optimization pass on the hash in
the future. In particular, Node/V8 now has native bigint support, which
is almost certainly faster than the `long` library.

1. microsoft/vscode#88386
@DonJayamanne
Copy link
Contributor

Agreed, fails. Trying to use this in the Python extension as well, and kaboom.
Couldn't find any reason for this.

@anonimitoraf
Copy link

Any updates on this?

@bpasero
Copy link
Member

bpasero commented May 4, 2020

I have a feeling this does not reproduce with our exploration builds. Can you try?

We are building exploration builds that use a much newer version of our UI framework (Electron version 8.x). I wonder if this issue reproduces with one of these builds, could you try? Download:

@DonJayamanne
Copy link
Contributor

@bpasero Tried and works (am to start a worker thread and things work as expected).
Thanks.

@bpasero bpasero added electron Issues and items related to Electron fixed-in-electron-8 upstream Issue identified as 'upstream' component related (exists outside of VS Code) labels May 6, 2020
@bpasero
Copy link
Member

bpasero commented May 7, 2020

This seems to be more of a debugging problem than actually being able to use worker threads. E.g. I created an extension that uses this and it seems to work fine unless I debug.

@DonJayamanne
Copy link
Contributor

DonJayamanne commented May 7, 2020

I created an extension that uses this and it seems to work fine unless I debug.

FYI - It worked for me while debugging the extension.

@bpasero
Copy link
Member

bpasero commented May 7, 2020

What I mean to say is: it works for me even in Electron 7. But not when debugging.

@deepak1556 deepak1556 added this to the July 2020 milestone Jul 21, 2020
@deepak1556 deepak1556 modified the milestones: July 2020, August 2020 Jul 29, 2020
@deepak1556
Copy link
Collaborator

Does this still crash with latest insiders ?

@deepak1556 deepak1556 added info-needed Issue requires more information from poster and removed fixed-in-electron-8 labels Aug 28, 2020
@connor4312
Copy link
Member Author

Yep it seems to work in electron 9.

(note that debugging the threads doesn't work either in Electron or in Node nodejs/node#26609)

@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
electron Issues and items related to Electron info-needed Issue requires more information from poster upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

5 participants