Skip to content

Conversation

@legendecas
Copy link
Member

@legendecaslegendecas commented Apr 19, 2020

instead of emitting async init with the receiver of the callback.

Fixes: #32898
Related: #32928

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

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. node-api Issues and PRs related to the Node-API. labels Apr 19, 2020
@legendecaslegendecas marked this pull request as ready for review April 21, 2020 02:17
@Qard
Copy link
Member

Qard commented Apr 21, 2020

This duplicates a lot of code from AsyncWrap. It also appears to be a major breaking change to N-API which I was hoping to avoid as it makes it difficult to backport executionAsyncResource related code. Not sure how I feel about this. 😟

@legendecas
Copy link
MemberAuthor

This duplicates a lot of code from AsyncWrap.

Yes, this is for AsyncWrap not suitable in the case since the resource object in the N-API may have no internal slot, which fails the BaseObject's assertion.

It also appears to be a major breaking change to N-API

Could you elaborate on how this would be breaking to existing N-API codes? It seems to me doesn't break codes and behaviors? (They are not working as expected already).

@Qard
Copy link
Member

Qard commented Apr 22, 2020

cc @nodejs/n-api @nodejs/diagnostics

The approach seems reasonable. Could use some more review from people that know n-api better though, especially around ABI impact.

@mhdawson
Copy link
Member

I think we discussed this in the last N-API team meeting and @legendecas just needs to find some time to get back to it.

@legendecaslegendecasforce-pushed the napi_async_context branch 3 times, most recently from eb5fdef to 242acadCompareOctober 6, 2020 18:15
@legendecas
Copy link
MemberAuthor

@addaleax@mhdawson@Flarna Sorry for the terrible long delay. I've updated the PR, PTAL :)

Qard
Qard approved these changes Oct 7, 2020
Copy link
Member

@QardQard left a comment

Choose a reason for hiding this comment

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

Overall LGTM, but might be good to do something with that unused resource or people might get confused if they try to use a different resource and it silently ignores it. 🤔

src/node_api.cc Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Should we perhaps use the resource_object to warn if it's different than the object contained in the AsyncContext?

Copy link
Member

Choose a reason for hiding this comment

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

@quad I see what you mean, but that might be a breaking change and we don't have breaking changes for N-API methods. If we felt strongly about it we should add a new method without the parameter and doc deprecate the existing method (but not remove of course). I think we did something similar for another API in terms of indicate /** ignored */

Copy link
Member

Choose a reason for hiding this comment

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

I was just thinking a log message warning, no change in behaviour. Is that still considered breaking? Either way, not blocking on that. Just a thought that it'd be nice to have some indicator when the API is used improperly.

Copy link
Member

Choose a reason for hiding this comment

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

To my knowledge node has no logger. Logging to stdout/stderr tends to break command line tools.

But I think we should find a way how to deprecate something in NAPI in a way more visible to users like comments in doc.
I think a compile time warning like it is used for node::MakeCallback would be great.

Copy link
MemberAuthor

@legendecaslegendecasOct 15, 2020

Choose a reason for hiding this comment

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

I think a compile time warning like it is used for node::MakeCallback would be great.

AFAICT, it is not possible to emit compile-time warning without changing the API shapes. i.e. the signature of node::MakeCallback was migrated to the one with an additional parameter async_context. Though in the case of n_api, the deprecation is the parameter in the middle of the parameter list. So a new n-api function without the parameter will be required and the one existing can be deprecated.

Copy link
Member

@mhdawsonmhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

@aduh95aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Oct 16, 2020
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 16, 2020
@nodejs-github-bot
Copy link
Collaborator

@aduh95aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 16, 2020
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

instead of emit async init with receiver of the callback.
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

@FlarnaFlarna added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 31, 2020
@github-actionsgithub-actionsbot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 31, 2020
@github-actions
Copy link
Contributor

Landed in 5da2512...3a7537d

nodejs-github-bot pushed a commit that referenced this pull request Oct 31, 2020
instead of emit async init with receiver of the callback. PR-URL: #32930Fixes: #32898 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
@legendecaslegendecas deleted the napi_async_context branch October 31, 2020 06:29
targos pushed a commit that referenced this pull request Nov 3, 2020
instead of emit async init with receiver of the callback. PR-URL: #32930Fixes: #32898 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
@targostargos mentioned this pull request Nov 3, 2020
BethGriggs pushed a commit that referenced this pull request Dec 8, 2020
instead of emit async init with receiver of the callback. PR-URL: #32930Fixes: #32898 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
BethGriggs pushed a commit that referenced this pull request Dec 10, 2020
instead of emit async init with receiver of the callback. PR-URL: #32930Fixes: #32898 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
@BethGriggsBethGriggs mentioned this pull request Dec 10, 2020
BethGriggs pushed a commit that referenced this pull request Dec 15, 2020
instead of emit async init with receiver of the callback. PR-URL: #32930Fixes: #32898 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
tniessen added a commit that referenced this pull request Aug 15, 2023
nodejs-github-bot pushed a commit that referenced this pull request Aug 17, 2023
Refs: #32930 PR-URL: #49180 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
UlisesGascon pushed a commit that referenced this pull request Sep 10, 2023
Refs: #32930 PR-URL: #49180 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
targos pushed a commit that referenced this pull request Nov 27, 2023
Refs: #32930 PR-URL: #49180 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
Refs: nodejs/node#32930 PR-URL: nodejs/node#49180 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
Refs: nodejs/node#32930 PR-URL: nodejs/node#49180 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.node-apiIssues and PRs related to the Node-API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

n-api: napi_make_callback with async_hooks.executionAsyncResource

8 participants

@legendecas@Qard@mhdawson@nodejs-github-bot@addaleax@gabrielschulhof@Flarna@aduh95