-
Notifications
You must be signed in to change notification settings - Fork 3
chore: Added nan handling documentation. #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,7 +93,39 @@ Memory comparison between standard Node.js 22 and pointer-compressed Node.js 25 | |
| | `@napi-rs/uuid` | Rust N-API | ✓ Works | | ||
| | `@node-rs/argon2` | Rust N-API | ✓ Works | | ||
|
|
||
| **Non-N-API native addons may crash.** Addons using the older V8 native addon API (like `better-sqlite3`) are not compatible with pointer compression and will segfault. Always prefer N-API-based alternatives. | ||
| **Non-N-API native addons may crash.** Addons using the older V8 native addon API (like `better-sqlite3`) are not compatible with pointer compression and can segfault. Packages that rely on `nan` are especially affected. Always prefer N-API-based alternatives. | ||
|
|
||
| ### Workarounds for Non-N-API Addons | ||
|
|
||
| If your dependency uses `nan` and does not provide binaries built for this runtime, you must force a local rebuild of its native addon. | ||
|
|
||
| If the package in `node_modules` still contains source files, try a normal rebuild: | ||
|
|
||
| ```bash | ||
| cd node_modules/<package-name> | ||
| pnpm install --ignore-scripts | ||
| pnpm run rebuild | ||
| ``` | ||
|
|
||
| Some packages on npm do not ship source files needed to rebuild. In these cases, you may need to fetch the source from the git repository, copy it back into `node_modules`, and run a manual rebuild. | ||
|
|
||
| #### Known affected package example | ||
|
|
||
| ##### `@datadog/pprof` | ||
|
|
||
| This was tested against [@datadog/pprof](https://www.npmjs.com/package/@datadog/pprof) 5.13.5. | ||
|
|
||
| ```bash | ||
| cd node_modules/@datadog/pprof | ||
| pnpm install --ignore-scripts | ||
| PPROF_VERSION=$(node -p "require('./package.json').version") | ||
| PPROF_REPO=$(node -p "require('./package.json').repository.url.replace('git+', '')") | ||
| git clone -q --depth=1 --branch=v$PPROF_VERSION $PPROF_REPO /tmp/pprof-nodejs > /dev/null 2>&1 | ||
| mv /tmp/pprof-nodejs/{binding.gyp,bindings} . | ||
| rm -rf /tmp/pprof-nodejs | ||
| pnpm run rebuild | ||
| cd ../../.. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this really work? Doesn't pprof use node-gyp to build which in turn is also a nan dependency? doesn't node-gyp also need to be rebuilt? |
||
| ``` | ||
|
|
||
| ## How It Works | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.