Skip to content

node-api: convert NewEnv to node_napi_env__::New - #57834

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
vmoroz:pr/convert_newenv_to_a_method
Apr 19, 2025
Merged

node-api: convert NewEnv to node_napi_env__::New#57834
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
vmoroz:pr/convert_newenv_to_a_method

Conversation

@vmoroz

Copy link
Copy Markdown
Member

Convert local v8impl::NewEnv function to the node_napi_env__::New method.
The new method helps creating new Node-API environment by any code that includes the node_api_internals.h header file.
There are no changes to the function bodies except for moving them to the top of the file.
The ThrowNodeApiVersionError had to be moved because the node_napi_env__::New uses it.

This change is required for the new C-based Node.js embedding API - PR #54660.
Since the PR #54660 is too big, it was decided in a Node-API meeting to split it up into smaller PRs.
This is the first PR in the series.

@vmorozvmoroz added the node-api Issues and PRs related to the Node-API. label Apr 11, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/node-api

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Apr 11, 2025
@legendecaslegendecas moved this from Need Triage to In Progress in Node-API Team ProjectApr 11, 2025
@codecov

codecovBot commented Apr 11, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 37.03704% with 17 lines in your changes missing coverage. Please review.

Project coverage is 90.15%. Comparing base (795dd8e) to head (66c68ed).
Report is 51 commits behind head on main.

Files with missing linesPatch %Lines
src/node_api.cc37.03%15 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #57834 +/- ##
==========================================
- Coverage 90.24% 90.15% -0.09% 
==========================================
Files 630 628 -2 Lines 185470 185036 -434 Branches 36375 36234 -141 ==========================================
- Hits 167371 166823 -548 - Misses 10993 11164 +171 + Partials 7106 7049 -57 
Files with missing linesCoverage Δ
src/node_api_internals.h100.00% <ø> (ø)
src/node_api.cc76.16% <37.03%> (+0.02%)⬆️

... and 50 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.

@mertcanaltinmertcanaltin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@legendecaslegendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 12, 2025
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 12, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@vmoroz

Copy link
Copy Markdown
MemberAuthor

The build fails because VS2022 build for ARM64 hits out of memory issue:

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\tuple(132,1): fatal error C1060: compiler is out of heap space [C:\workspace\node-compile-windows\node\tools\v8_gypfiles\v8_initializers.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\type_traits(1527,92): fatal error C1060: compiler is out of heap space [C:\workspace\node-compile-windows\node\tools\v8_gypfiles\v8_initializers.vcxproj]

I wonder if it is a known issue and someone is looking at it, or I should see where to add the /Zm compiler option to limit the memory use.

@mhdawsonmhdawson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@StefanStojanovic

Copy link
Copy Markdown
Contributor

The build fails because VS2022 build for ARM64 hits out of memory issue:

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\tuple(132,1): fatal error C1060: compiler is out of heap space [C:\workspace\node-compile-windows\node\tools\v8_gypfiles\v8_initializers.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\type_traits(1527,92): fatal error C1060: compiler is out of heap space [C:\workspace\node-compile-windows\node\tools\v8_gypfiles\v8_initializers.vcxproj]

I wonder if it is a known issue and someone is looking at it, or I should see where to add the /Zm compiler option to limit the memory use.

Hello. Yes, this is a known problem, although it doesn't occur often. We are already setting /Zm2000. It could be increased e.g., /Zm3000, but that will probably not be necessary. The reason for this is that in Node.js v24 and later, we'll be moving from MSVC to ClangCL. This is a PR making it official which should land sometime this week. With ClangCL, we are not using PCH, as we have enabled ccache, so this will not be an issue.

I have restarted CI for this, so let's see if it succeeds this time.

@lpincalpinca added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 19, 2025
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 19, 2025
@nodejs-github-bot
nodejs-github-bot merged commit c326200 into nodejs:mainApr 19, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in c326200

@github-project-automationgithub-project-automationBot moved this from In Progress to Done in Node-API Team ProjectApr 19, 2025
@vmoroz
vmoroz deleted the pr/convert_newenv_to_a_method branch April 20, 2025 03:15
@vmoroz

Copy link
Copy Markdown
MemberAuthor

@StefanStojanovic and @lpinca , thank you for helping with the PR completion!

RafaelGSS pushed a commit that referenced this pull request May 1, 2025
PR-URL: #57834
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
RafaelGSS pushed a commit that referenced this pull request May 2, 2025
PR-URL: #57834
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
aduh95 pushed a commit that referenced this pull request May 6, 2025
PR-URL: #57834
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
aduh95 pushed a commit that referenced this pull request May 6, 2025
PR-URL: #57834
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
RafaelGSS pushed a commit that referenced this pull request May 14, 2025
PR-URL: #57834
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
aduh95 pushed a commit that referenced this pull request May 16, 2025
PR-URL: #57834
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
aduh95 pushed a commit that referenced this pull request May 17, 2025
PR-URL: #57834
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
aduh95 pushed a commit that referenced this pull request May 18, 2025
PR-URL: #57834
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
aduh95 pushed a commit that referenced this pull request May 19, 2025
PR-URL: #57834
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
@ghostghost mentioned this pull request Jun 8, 2025
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++.needs-ciPRs that need a full CI run.node-apiIssues and PRs related to the Node-API.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

8 participants

@vmoroz@nodejs-github-bot@StefanStojanovic@jasnell@legendecas@mhdawson@mertcanaltin@lpinca