Skip to content

Conversation

@addaleax
Copy link
Member

@addaleax addaleax commented Oct 30, 2025

Edit: Split out #60512 from this PR and marking this PR as blocked on it

Including node.h should not result in all of Node-API also being available to callers. Users who want node_api.h contents should explicitly include that header.

We currently include it specifically for napi_addon_register_func; by moving that into node_api_types.h and including that instead, we can reduce unintentionally included API surface a lot.

Refs: #60345 (comment)

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/node-api

@addaleax addaleax requested a review from legendecas October 30, 2025 15:31
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Oct 30, 2025
@addaleax addaleax added semver-major PRs that contain breaking changes and should be released in the next major version. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Oct 30, 2025
"Experimental features may be unstable."
#endif
#endif

Copy link
Member Author

Choose a reason for hiding this comment

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

For context, this was moved because this file actually depends on these macros being applied, so previously there was an implicit requirement that js_native_api.h would need to be included prior to this file, either directly or indirectly.

Copy link
Member

Choose a reason for hiding this comment

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

I believe this is not a semver-major change. I'm wondering if this can be split into a PR so that it can be backport-ed? Usually we don't mark node-api header changes as semver-major and node-api headers are sync-ed across LTS versions.

Copy link
Member Author

Choose a reason for hiding this comment

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

@legendecas Yup, that makes a ton of sense. Opened #60512 with the non-breaking changes to Node-API headers.

@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 30, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 30, 2025
@nodejs-github-bot
Copy link
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/69960/

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.55%. Comparing base (dbe45b7) to head (73d929d).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #60496      +/-   ##
==========================================
+ Coverage   88.54%   88.55%   +0.01%     
==========================================
  Files         704      704              
  Lines      207843   207843              
  Branches    40044    40041       -3     
==========================================
+ Hits       184028   184057      +29     
+ Misses      15858    15834      -24     
+ Partials     7957     7952       -5     
Files with missing lines Coverage Δ
src/node.h 95.91% <ø> (ø)

... and 46 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodejs-github-bot
Copy link
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/69963/

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Oct 31, 2025

addaleax added a commit to addaleax/node that referenced this pull request Oct 31, 2025
This means that `node.h` can include only this file, instead of
the entirety of `node_api.h`.

Split out from nodejs#60496 since
it was rightfully pointed out that the breaking part of the change
should not touch Node-API headers.
@addaleax addaleax added the blocked PRs that are blocked by other issues or PRs. label Oct 31, 2025
@addaleax addaleax marked this pull request as draft October 31, 2025 14:01
nodejs-github-bot pushed a commit that referenced this pull request Nov 2, 2025
This means that `node.h` can include only this file, instead of
the entirety of `node_api.h`.

Split out from #60496 since
it was rightfully pointed out that the breaking part of the change
should not touch Node-API headers.

PR-URL: #60512
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@legendecas
Copy link
Member

Sorry for being late. This needs a rebase after #60512 landed.

Including `node.h` should not result in all of Node-API also being
available to callers. Users who want `node_api.h` contents should
explicitly include that header.

We currently include it specifically for `napi_addon_register_func`;
by moving that into `node_api_types.h` and including that instead,
we can reduce unintentionally included API surface a lot.

Refs: nodejs#60345 (comment)
@addaleax addaleax force-pushed the node-h-only-include-node-api-types.h branch from 617271c to 73d929d Compare November 2, 2025 18:24
@addaleax addaleax marked this pull request as ready for review November 2, 2025 18:24
@addaleax addaleax added review wanted PRs that need reviews. and removed blocked PRs that are blocked by other issues or PRs. labels Nov 2, 2025
@addaleax
Copy link
Member Author

addaleax commented Nov 2, 2025

@legendecas Yep, done! And no worries at all, your input here has been great.

@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 3, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 3, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Nov 3, 2025

Sign up for free to 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++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. review wanted PRs that need reviews. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants