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

Add success return value in diagnostics_channel unsubscribe #40433

Closed
wants to merge 2 commits into from

Conversation

@simon-id
Copy link
Contributor

@simon-id simon-id commented Oct 12, 2021

This PR adds two things to the unsubscribe method in diagnostics_channel module:

  • Add a returned boolean that returns true if a subscriber was actually removed, and false if it was not found

Can be used for example like this:

// this will remove every instance of the subscriber, not just the first one
while (channel.unsubcribe(subscriber)) {}

This is currently not possible without messing with the private channel._subscribers property.

  • Add the unsubscribe method to non-active channels

Currently if a user tries to use the unsubscribe method on a non-active Channel, it will throw channel.unsubscribe is not a function. This doesn't happen if the channel is an instance of ActiveChannel.
Since the user should not be aware of a difference between (non-active) Channel and ActiveChannel, the unsubscribe method should be present in both.

@simon-id simon-id marked this pull request as draft Oct 12, 2021
@targos
Copy link
Member

@targos targos commented Oct 13, 2021

@simon-id simon-id changed the title Add unsubscribe method to non-active channels Add success return value in diagnostics_channel unsubscribe Oct 13, 2021
@simon-id simon-id marked this pull request as ready for review Oct 13, 2021
Copy link
Member

@vdeturckheim vdeturckheim left a comment

LGTM. I am not sure on wether changing the return value of a method is a breaking change (in this context, moving from undefined to boolean)

@simon-id
Copy link
Contributor Author

@simon-id simon-id commented Oct 13, 2021

I am not sure on wether changing the return value of a method is a breaking change (in this context, moving from undefined to boolean)

I didn't think about that, you might be right. But since diagnostics_channel is in Stability: 1 - Experimental, that's not a problem is it ?

@vdeturckheim
Copy link
Member

@vdeturckheim vdeturckheim commented Oct 13, 2021

@Flarna
Copy link
Member

@Flarna Flarna commented Oct 13, 2021

Currently if a user tries to use the unsubscribe method on a non-active Channel, it will throw channel.unsubscribe is not a function.

Could you add a test for this scenario?

@simon-id
Copy link
Contributor Author

@simon-id simon-id commented Oct 13, 2021

Could you add a test for this scenario?

This case is implicitly tested here I think, or is that not what you mean ?

Qard
Qard approved these changes Oct 13, 2021
Flarna
Flarna approved these changes Oct 13, 2021
@nodejs-github-bot

This comment has been hidden.

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Oct 13, 2021

Copy link
Member

@mhdawson mhdawson left a comment

LGTM

Copy link
Member

@RafaelGSS RafaelGSS left a comment

LGTM.

bengl
bengl approved these changes Oct 14, 2021
Lxxyx
Lxxyx approved these changes Oct 15, 2021
@simon-id simon-id reopened this Oct 19, 2021
@simon-id
Copy link
Contributor Author

@simon-id simon-id commented Oct 19, 2021

Squashed the changes into two logical commits, and (i think) fixed the author issue. I think the commit queue should work now.

@vdeturckheim
Copy link
Member

@vdeturckheim vdeturckheim commented Oct 19, 2021

@Flarna good for you if I re-add it to the queue ?

@targos
Copy link
Member

@targos targos commented Oct 19, 2021

@vdeturckheim it won't work because there was a push after the last CI run.

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Oct 19, 2021

@vdeturckheim
Copy link
Member

@vdeturckheim vdeturckheim commented Oct 19, 2021

Good catch @targos . I just restarted it

@github-actions
Copy link

@github-actions github-actions bot commented Oct 19, 2021

Commit Queue failed
- Loading data for nodejs/node/pull/40433
✔  Done loading data for nodejs/node/pull/40433
----------------------------------- PR info ------------------------------------
Title      Add success return value in diagnostics_channel unsubscribe (#40433)
Author     simon-id  (@simon-id, first-time contributor)
Branch     simon-id:patch-1 -> nodejs:master
Labels     semver-minor, author ready, diagnostics_channel
Commits    2
 - lib: add return value for DC channel.unsubscribe
 - lib: add unsubscribe method to non-active DC channels
Committers 1
 - simon-id 
PR-URL: https://github.com/nodejs/node/pull/40433
Reviewed-By: Vladimir de Turckheim 
Reviewed-By: Stephen Belanger 
Reviewed-By: Gerhard Stöbich 
Reviewed-By: Michael Dawson 
Reviewed-By: Bryan English 
Reviewed-By: Zijian Liu 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/40433
Reviewed-By: Vladimir de Turckheim 
Reviewed-By: Stephen Belanger 
Reviewed-By: Gerhard Stöbich 
Reviewed-By: Michael Dawson 
Reviewed-By: Bryan English 
Reviewed-By: Zijian Liu 
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last review:
   ⚠  - lib: add return value for DC channel.unsubscribe
   ⚠  - lib: add unsubscribe method to non-active DC channels
   ℹ  This PR was created on Tue, 12 Oct 2021 19:16:54 GMT
   ✔  Approvals: 6
   ✔  - Vladimir de Turckheim (@vdeturckheim): https://github.com/nodejs/node/pull/40433#pullrequestreview-778650881
   ✔  - Stephen Belanger (@Qard): https://github.com/nodejs/node/pull/40433#pullrequestreview-778754474
   ✔  - Gerhard Stöbich (@Flarna): https://github.com/nodejs/node/pull/40433#pullrequestreview-778766673
   ✔  - Michael Dawson (@mhdawson) (TSC): https://github.com/nodejs/node/pull/40433#pullrequestreview-779078155
   ✔  - Bryan English (@bengl): https://github.com/nodejs/node/pull/40433#pullrequestreview-780077439
   ✔  - Zijian Liu (@Lxxyx): https://github.com/nodejs/node/pull/40433#pullrequestreview-780489282
   ✔  Last GitHub Actions successful
   ℹ  Last Full PR CI on 2021-10-19T12:18:04Z: https://ci.nodejs.org/job/node-test-pull-request/40367/
- Querying data for job/node-test-pull-request/40367/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/1359595185

@github-actions
Copy link

@github-actions github-actions bot commented Oct 19, 2021

Landed in 0f78d26...07bbb07

@github-actions github-actions bot closed this Oct 19, 2021
nodejs-github-bot added a commit that referenced this issue Oct 19, 2021
PR-URL: #40433
Reviewed-By: Vladimir de Turckheim <[email protected]>
Reviewed-By: Stephen Belanger <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Bryan English <[email protected]>
Reviewed-By: Zijian Liu <[email protected]>
nodejs-github-bot added a commit that referenced this issue Oct 19, 2021
PR-URL: #40433
Reviewed-By: Vladimir de Turckheim <[email protected]>
Reviewed-By: Stephen Belanger <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Bryan English <[email protected]>
Reviewed-By: Zijian Liu <[email protected]>
@vdeturckheim
Copy link
Member

@vdeturckheim vdeturckheim commented Oct 19, 2021

Congrats @simon-id for this first PR merged!

targos added a commit that referenced this issue Oct 23, 2021
PR-URL: #40433
Reviewed-By: Vladimir de Turckheim <[email protected]>
Reviewed-By: Stephen Belanger <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Bryan English <[email protected]>
Reviewed-By: Zijian Liu <[email protected]>
targos added a commit that referenced this issue Oct 23, 2021
PR-URL: #40433
Reviewed-By: Vladimir de Turckheim <[email protected]>
Reviewed-By: Stephen Belanger <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Bryan English <[email protected]>
Reviewed-By: Zijian Liu <[email protected]>
targos added a commit that referenced this issue Nov 8, 2021
Notable changes:

doc:
  * add VoltrexMaster to collaborators (voltrexmaster) #40566
esm:
  * (SEMVER-MINOR) add support for JSON import assertion (Antoine du Hamel) #40250
lib:
  * (SEMVER-MINOR) add unsubscribe method to non-active DC channels (simon-id) #40433
  * (SEMVER-MINOR) add return value for DC channel.unsubscribe (simon-id) #40433
v8:
  * (SEMVER-MINOR) multi-tenant promise hook api (Stephen Belanger) #39283

PR-URL: TODO
targos added a commit that referenced this issue Nov 8, 2021
Notable changes:

doc:
  * add VoltrexMaster to collaborators (voltrexmaster) #40566
esm:
  * (SEMVER-MINOR) add support for JSON import assertion (Antoine du Hamel) #40250
lib:
  * (SEMVER-MINOR) add unsubscribe method to non-active DC channels (simon-id) #40433
  * (SEMVER-MINOR) add return value for DC channel.unsubscribe (simon-id) #40433
v8:
  * (SEMVER-MINOR) multi-tenant promise hook api (Stephen Belanger) #39283

PR-URL: #40758
@targos targos mentioned this pull request Nov 8, 2021
targos added a commit that referenced this issue Nov 9, 2021
Notable changes:

doc:
  * add VoltrexMaster to collaborators (voltrexmaster) #40566
esm:
  * (SEMVER-MINOR) add support for JSON import assertion (Antoine du Hamel) #40250
lib:
  * (SEMVER-MINOR) add unsubscribe method to non-active DC channels (simon-id) #40433
  * (SEMVER-MINOR) add return value for DC channel.unsubscribe (simon-id) #40433
v8:
  * (SEMVER-MINOR) multi-tenant promise hook api (Stephen Belanger) #39283

PR-URL: #40758
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet