Skip to content
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

Node v20.5.0 issue and fix #43

Closed
zack09holland opened this issue Aug 9, 2023 · 5 comments
Closed

Node v20.5.0 issue and fix #43

zack09holland opened this issue Aug 9, 2023 · 5 comments

Comments

@zack09holland
Copy link
Contributor

I was getting this error originally

Error: Could not locate the bindings file. Tried:
 → /home/user/Documents/workspace/repos/.../.../node_modules/node-postal/build/expand.node
...
...continues on for a bit
...

When on Node v14.18.0, you have to do a node-gyp rebuild within the node-postal module folder, which builds successfully and will recreate the bindings. However when I would do this on Node v20.5.0 it was failing during the make stage

make: *** [expand.target.mk:115: Release/obj.target/expand/src/expand.o] Error 1
make: Leaving directory '/home/user/Documents/workspace/repos/.../.../node_modules/node-postal/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/zholland/.nvm/versions/node/v20.5.0/lib/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Linux 6.0.6-76060006-generic
gyp ERR! command "/home/user/.nvm/versions/node/v20.5.0/bin/node" "/home/user/.nvm/versions/node/v20.5.0/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/user/Documents/workspace/repos/.../.../node_modules/node-postal
gyp ERR! node -v v20.5.0
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok 

Spent a few hours researching both of those issues. I went through the debug logs and saw an error

../src/expand.cc: In function ‘void init(v8::Local<v8::Object>)’:
../src/expand.cc:136:47: error: ‘class v8::Object’ has no member named ‘CreationContext’; did you mean ‘GetCreationContext’?
  136 |     v8::Local<v8::Context> context = exports->CreationContext();
      |                                                                                                  ^~~~~~~~~~~~~~~
      |                                                                                                  GetCreationContext

On an entirely different packages github issues post, someone commented with a change to get the correct JS context and sure enough I was able to run node-gyp rebuild within the node-postal directory to rebind it and the errors went away

Within parser.cc and expand.cc change:
v8::Local<v8::Context> context = exports->CreationContext();

to

v8::Local<v8::Context> context = exports->GetCreationContext().ToLocalChecked();

@tomups
Copy link

tomups commented Sep 20, 2023

Faced this problem as well when trying to use it with Node 20, with the above fix it did indeed work, but still I am sticking to Node 18 for now until this is maybe integrated.

@zack09holland I think your solution would be good PR material :)
(EDIT: I just saw there is indeed a PR here #44 but without CI tests...)

@missinglink would this be accepted and a new package version published for Node 20 compatibility?

@missinglink
Copy link
Contributor

I would happily accept any patch which improves the supported versions.

Since it's a pain to test manually, it would be best if the code was accompanied by a CI script which tests it on every release.

@zack09holland
Copy link
Contributor Author

I can certainly write up some CI tests to go along with my PR.

Mostly wanted to document my findings in case someone else was encountering the same issue.

@missinglink
Copy link
Contributor

Please test the code in #44 and let me know if this issue is resolved.

@zack09holland
Copy link
Contributor Author

@missinglink I had created this issue just to document my findings. Changes in #44 is the pull request I opened up as well. This issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants