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

worker: make terminate() resolve for unref’ed Workers #29484

Closed
wants to merge 1 commit into from

Conversation

addaleax
Copy link
Member

@addaleax addaleax commented Sep 7, 2019

Once worker.terminate() is called, the Worker instance will be
destroyed as soon as possible anyway, so in order to make
the Promise returned by worker.terminate() resolve always,
it should be okay to just call .ref() on it and keep the main
event loop alive temporarily.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Once `worker.terminate()` is called, the Worker instance will be
destroyed as soon as possible anyway, so in order to make
the Promise returned by `worker.terminate()` resolve always,
it should be okay to just call `.ref()` on it and keep the main
event loop alive temporarily.
@addaleax addaleax added the worker Issues and PRs related to Worker support. label Sep 7, 2019
@nodejs-github-bot
Copy link
Collaborator

@Fishrock123
Copy link
Contributor

Shouldn't microTasks still be called after we get a success callback in C++? What am I missing?

@addaleax
Copy link
Member Author

addaleax commented Sep 9, 2019

@Fishrock123 I’m not sure I understand your question, but the way that this change works is that it keeps the Worker’s uv_async_t(s) alive until its exit notification arrives on the main loop, and the microtask queue is not really involved here.

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 9, 2019
addaleax added a commit that referenced this pull request Sep 9, 2019
Once `worker.terminate()` is called, the Worker instance will be
destroyed as soon as possible anyway, so in order to make
the Promise returned by `worker.terminate()` resolve always,
it should be okay to just call `.ref()` on it and keep the main
event loop alive temporarily.

PR-URL: #29484
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@addaleax
Copy link
Member Author

addaleax commented Sep 9, 2019

Landed in 2833a0d

@addaleax addaleax closed this Sep 9, 2019
@addaleax addaleax deleted the terminate-unrefed branch September 9, 2019 20:28
targos pushed a commit that referenced this pull request Sep 20, 2019
Once `worker.terminate()` is called, the Worker instance will be
destroyed as soon as possible anyway, so in order to make
the Promise returned by `worker.terminate()` resolve always,
it should be okay to just call `.ref()` on it and keep the main
event loop alive temporarily.

PR-URL: #29484
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@BridgeAR BridgeAR mentioned this pull request Sep 24, 2019
BridgeAR pushed a commit that referenced this pull request Sep 25, 2019
Once `worker.terminate()` is called, the Worker instance will be
destroyed as soon as possible anyway, so in order to make
the Promise returned by `worker.terminate()` resolve always,
it should be okay to just call `.ref()` on it and keep the main
event loop alive temporarily.

PR-URL: #29484
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. worker Issues and PRs related to Worker support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants