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 26 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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@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

@addaleax
Copy link
Member Author

addaleax commented Nov 4, 2025

@nodejs/tsc I'd leave this tagged semver-major simply to err on the side of caution, but this also means I'd need two approvals from y'all 🙂

@addaleax addaleax added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 4, 2025
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Nov 4, 2025
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/60496
✔  Done loading data for nodejs/node/pull/60496
----------------------------------- PR info ------------------------------------
Title      src: include `node_api_types.h` instead of `node_api.h` in `node.h` (#60496)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     addaleax:node-h-only-include-node-api-types.h -> nodejs:main
Labels     c++, semver-major, lib / src, needs-ci, review wanted, commit-queue-squash
Commits    1
 - src: include `node_api_types.h` instead of `node_api.h` in `node.h`
Committers 1
 - Anna Henningsen <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/60496
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/60496
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Thu, 30 Oct 2025 15:31:25 GMT
   ✔  Approvals: 5
   ✔  - Juan José Arboleda (@juanarbol): https://github.com/nodejs/node/pull/60496#pullrequestreview-3400508206
   ✔  - Chengzhong Wu (@legendecas) (TSC): https://github.com/nodejs/node/pull/60496#pullrequestreview-3408999164
   ✔  - Michaël Zasso (@targos) (TSC): https://github.com/nodejs/node/pull/60496#pullrequestreview-3416771399
   ✔  - Filip Skokan (@panva) (TSC): https://github.com/nodejs/node/pull/60496#pullrequestreview-3416773895
   ✔  - Darshan Sen (@RaisinTen) (TSC): https://github.com/nodejs/node/pull/60496#pullrequestreview-3416825540
   ✘  Last GitHub CI failed
   ℹ  Last Full PR CI on 2025-11-03T16:28:47Z: https://ci.nodejs.org/job/node-test-pull-request/70025/
- Querying data for job/node-test-pull-request/70025/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/19072542185

addaleax added a commit that referenced this pull request Nov 4, 2025
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)
PR-URL: #60496
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
@addaleax
Copy link
Member Author

addaleax commented Nov 4, 2025

Landed in 7d2bc52

@addaleax addaleax closed this Nov 4, 2025
@addaleax addaleax deleted the node-h-only-include-node-api-types.h branch November 4, 2025 14:48
@addaleax addaleax removed the review wanted PRs that need reviews. label Nov 4, 2025
aduh95 pushed a commit that referenced this pull request Nov 5, 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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
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-failed An error occurred while landing this pull request using GitHub Actions. 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. 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.

7 participants