Skip to content

worker: handle calling terminate when kHandler is null - #28370

Closed
elyalvarado wants to merge 5 commits into
nodejs:masterfrom
elyalvarado:terminate-with-null-handlers
Closed

worker: handle calling terminate when kHandler is null#28370
elyalvarado wants to merge 5 commits into
nodejs:masterfrom
elyalvarado:terminate-with-null-handlers

Conversation

@elyalvarado

@elyalvaradoelyalvarado commented Jun 21, 2019

Copy link
Copy Markdown
Contributor

This PR makes a change to the Worker.terminate() method when
called if the kHandler is null. Before this pull request it was returning
undefined, but the API is expecting a promise. With the changes in
this PR if terminate is called and kHandler is null a resolved Promise
is returned even if a callback is passed, to be consistent with the API
surface, and with always return promises.

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

@nodejs-github-botnodejs-github-bot added the worker Issues and PRs related to Worker support. label Jun 21, 2019
Comment threadlib/internal/worker.js Outdated
@elyalvarado
elyalvaradoforce-pushed the terminate-with-null-handlers branch from 77806ac to c59a793CompareJune 22, 2019 12:33

@addaleaxaddaleax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to run make lint and address the errors, but otherwise this looks good to me :)

@TimothyGuTimothyGu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than this comment and @addaleax’s :)

Comment threadlib/internal/worker.js Outdated
@jasnelljasnell added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Jun 23, 2019
@elyalvarado
elyalvaradoforce-pushed the terminate-with-null-handlers branch from c59a793 to 4222cd9CompareJune 23, 2019 22:34
@elyalvarado

Copy link
Copy Markdown
ContributorAuthor

Pushed the following changes:

  • make lint now passing, this included rewording the commit messages to include the subsystem
  • Changed the return statements to print the deprecation warning if a callback is passed, and still return a promise if kHandle is null

@elyalvaradoelyalvarado changed the title handle calling terminate on a worker when kHandler is nullworker: handle calling terminate when kHandler is nullJun 23, 2019

@khriztianmorenokhriztianmoreno left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@addaleaxaddaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 4, 2019
@addaleax

Copy link
Copy Markdown
Member

CI (without rebasing due to the merge commit): https://ci.nodejs.org/job/node-test-pull-request/24264/

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment threadtest/parallel/test-worker-terminate-null-handler.js Outdated
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@Trott

Copy link
Copy Markdown
Member

Can you remove the merge commit? Our Ci does not handle them well.

This PR makes a change to the Worker.terminate() when called if the
kHandler is null. Before this pull request it was returning undefined,
but the API is expecting a promise. With the changes in this PR if
terminate is called a Promise.resolve() is returned, unless a callback
is passed in which case the old behavior stays (returns undefined).
This change makes terminate always return a promise even if kHandler
is null
The deprecation warning is printed even if the kHandler is null
...and make the linter happy
@Trott
Trottforce-pushed the terminate-with-null-handlers branch from fd7f67e to 3916e59CompareJuly 30, 2019 23:38
@Trott

Copy link
Copy Markdown
Member

Rebased against master and force pushed to eliminate the merge commit so we can run Ci and get this landed....

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@elyalvarado

Copy link
Copy Markdown
ContributorAuthor

Thanks @Trott I was precisely going to ask how should I eliminate the merge commit. Now I know 😉. You all rock 🎸

Trott pushed a commit to Trott/io.js that referenced this pull request Jul 31, 2019
This PR makes a change to the Worker.terminate() when called if the
kHandler is null. Before this pull request it was returning undefined,
but the API is expecting a promise. With the changes in this PR if
terminate is called a Promise.resolve() is returned, unless a callback
is passed in which case the old behavior stays (returns undefined).
PR-URL: nodejs#28370
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@Trott

Copy link
Copy Markdown
Member

Landed in 9083a67.

Thanks for the contribution! 🎉

(If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.)

@TrottTrott closed this Jul 31, 2019
targos pushed a commit that referenced this pull request Aug 2, 2019
This PR makes a change to the Worker.terminate() when called if the
kHandler is null. Before this pull request it was returning undefined,
but the API is expecting a promise. With the changes in this PR if
terminate is called a Promise.resolve() is returned, unless a callback
is passed in which case the old behavior stays (returns undefined).
PR-URL: #28370
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@BridgeARBridgeAR mentioned this pull request Aug 6, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.code-and-learnIssues related to the Code-and-Learn events and PRs submitted during the events.workerIssues and PRs related to Worker support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@elyalvarado@addaleax@nodejs-github-bot@Trott@jasnell@khriztianmoreno@TimothyGu@BridgeAR