Repository navigation
node-addon-api addons broken by default on Node.js 20.12+ #52229
Description
Activity
- addedc++Issues and PRs that require attention from people who are familiar with C++.Issues and PRs that require attention from people who are familiar with C++.node-apiIssues and PRs related to Node-API.Issues and PRs related to Node-API.
on Mar 27, 2024 @addaleax do you have Experiemental enabled? If I remember correctly any such change should only have affected people using the Experiemental option?
From the PR
In keeping with the process of introducing new Node-APIs, this feature is guarded by NAPI_EXPERIMENTAL.
so I think that my assumption that it should only affect addons using NAPI_EXPERIMENTAL is correct.
@gabrielschulhof can you clarify as well. I think you were waiting on some PRs to make it into Node.js to address issues on the node-addon-api side of things.
If the issue is that #50060 wasn't highlighted in the release notes for 20.12.0, well that had over 400 commits and #50060 wasn't labelled as a
notable-change(or evensemver-minor). I only highlighted the equivalent in the release notes for Node.js 18.20.0 because it had an explicit backport PR.From the PR
In keeping with the process of introducing new Node-APIs, this feature is guarded by NAPI_EXPERIMENTAL.
so I think that my assumption that it should only affect addons using NAPI_EXPERIMENTAL is correct.
@mhdawson Yeah no, the opt-out of this behavior is experimental (behind
defined(NAPI_EXPERIMENTAL) && defined(NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT)). The PR description seemed to have been accurate for an initial version of the PR, though.do you have Experiemental enabled?
There’s a self-contained one-liner reproduction in the issue description. (Also ran this in a Docker image to make sure my personal environment is not having any effect.)
@richardlau Yeah, I was more thinking about the fact that #50060 should have been labeled as a breaking change, not that this should have been caught during the release 🙂
Reacted by Richard LauReached out to Gabriel through twitter message as well. I think there was likely a mix-up in the guards versus it being planned to affect existing addons not using NAPI_EXPERIMENTAL but would like to confirm with him.
@richardlau I've not managed to get in touch with @gabrielschulhof yet, but I'm wondering if we should revert the change on 20.x and 18.x. Having done the releases to do forsee any complications with that?
@mhdawson Would it be possible for the node-api team to discuss on Friday's meeting if reverting is something that should be done and open revert PRs against 20.x and 18.x if so?
FWIW for Node.js 18.x we have already have other fixes for regressions that warrant a release:
@richardlau thanks for confirming that. I'll make sure that we discuss Friday in the team meeintg and if we agree we should revert I'm happy to volunteer to create the revert PRs unless that is something the releaser can easily do as part of the release process.
@addaleax It was not our intention to break add-ons built without NAPI_EXPERIMENTAL.
At https://github.com/mongodb-js/kerberos/blob/main/src/kerberos.h#L7-L9
NAPI_EXPERIMENTALis defined. Thus, the add-on is exposed to experimental APIs, including the new nogc types. To get the add-on to build, it is sufficient to either- run the command as
CXXFLAGS='-DNODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT' npm i --build-from-source, or to - make any of the following changes to the add-on's code:
- keep NAPI_EXPERIMENTAL and add the NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT flag, or
- bump NAPI_VERSION to 7 and remove NAPI_EXPERIMENTAL, or
- do the work to support nogc types.
This should allow you to move past building the add-on. Thank you for being vigilant, and please keep an eye out for add-ons that break as a result of this change, because it is the first time that we're changing the API signature of otherwise stable APIs, even if we're keeping the ABI the same.
Reacted by Malyshev Stanislav- run the command as
- added a commit that references this issue
on Apr 8, 2024 - added a commit that references this issue
on Apr 19, 2024 - added a commit that references this issue
on Oct 28, 2024 github-actions commented
on May 22, 2026 on May 22, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on May 22, 2026 github-actions commented
on Jun 21, 2026 on Jun 21, 2026 – with GitHub ActionsContributorMore actionsThis issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 240 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.- moved this from Need Triage to Done in Node-API Team Project
on Jun 21, 2026
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Version
v20.12.0
Platform
Linux 6.5.0-26-generic #26~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Mar 12 10:22:43 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
node-api
What steps will reproduce the bug?
cd /tmp && nvm install 20.12.0 && npm i --build-from-source kerberos(or any other node-addon-api addon that usesObjectWrapor similar APIs)How often does it reproduce? Is there a required condition?
Consistently.
What is the expected behavior? Why is that the expected behavior?
Addon builds like it did prior to 0ac070c.
What do you see instead?
Additional information
This was introduced in 0ac070c / #50060. From the PR description, this seems like intentional breakage, so it may need a solution in node-addon-api, not here. If it was intentional breakage, calling this out more explicitly somewhere in the release notes would have been helpful imo. @gabrielschulhof