yamlscript icon indicating copy to clipboard operation
yamlscript copied to clipboard

ffi-napi does not work on new versions of Node

Open abdala opened this issue 10 months ago • 2 comments

Read more here:

  • https://github.com/node-ffi-napi/node-ffi-napi/issues/269
  • ffi-napi

The project seems abandoned.

abdala avatar Apr 14 '25 09:04 abdala

Thanks for the report.

Have you tested https://www.npmjs.com/package/@yaml/yamlscript on node 21+ yet?

I'll have a look soon.

ingydotnet avatar Apr 14 '25 14:04 ingydotnet

Yes, I tested it on v20.17.0 and v22.12.0

abdala avatar Apr 15 '25 11:04 abdala

@abdala

Hi. I finally got time to look into this.

I've confirmed that it doesn't work with nodes 16.10.0 and earlier and nodes 18.20.0 and later. IOW, It seems to work with every node version from 16.11.0 - 18.19.1.

On this commit: 18a4cfbc (HEAD -> nodejs-fix, origin/nodejs-fix) nodejs: WIP: you can run commands like:

rm -fr .cache/.local/ && make -C nodejs/ distclean && make -C nodejs/ test NODE-VERSION=18.19.1

with different node versions and get results like: https://gist.github.com/ingydotnet/9eaa1c83f356caa0dfc210fbebe2e6c5

I played around with koffi a bit but can't get it working yet.

Do you have any ideas?

PS. node versions listed here: https://nodejs.org/download/release/

ingydotnet avatar Jul 13 '25 20:07 ingydotnet

Hi again @abdala

I finally got this fixed and it appears to work with all NodeJS versions old and new.

I will release this as v0.2.4 soon but you can test it now by running this on the devel branch:

$ make -C libys/ install
make[1]: Entering directory '/home/ingy/src/yamlscript/libys'
mkdir -p /home/ingy/.local/include/
install -m 644 /home/ingy/src/yamlscript/libys/lib/graal_isolate.h /home/ingy/src/yamlscript/libys/lib/libys.0.2.3.h  /home/ingy/.local/include/
mkdir -p /home/ingy/.local/lib/
install -m 644 /home/ingy/src/yamlscript/libys/lib/libys.so.0.2.3 /home/ingy/.local/lib/
ln -fs libys.so.0.2.3 /home/ingy/.local/lib/libys.so
ln -fs libys.so.0.2.3 /home/ingy/.local/lib/libys.so.0
ln -fs libys.so.0.2.3 /home/ingy/.local/lib/libys.0.2.3.so
make[1]: Leaving directory '/home/ingy/src/yamlscript/libys'
$ NODE_PATH=nodejs/lib node -e 'YS = require("yamlscript"); ys = new YS(); console.log(ys.load(fs.readFileSync(0, "utf8")))' <<<$'!YS-v0:\nfoo:: sum(3 .. 9)'
{ foo: 42 }
$ 

Let me know if it works for you!

ingydotnet avatar Sep 13 '25 20:09 ingydotnet

PS Just did some testing against all node versions and it works all the way back to:

v12.8.0/ - 06-Aug-2019

ingydotnet avatar Sep 14 '25 19:09 ingydotnet

Hey @ingydotnet,

Thank you so much. I checked on version 20, 22 and 24. All good, all working! 🙌

abdala avatar Sep 15 '25 07:09 abdala

@abdala Thanks for testing.

I limited it to these versions https://github.com/yaml/yamlscript/blob/devel/nodejs/package.json#L9 because @makeomatic/ffi-napi requires 18.0.0+ and because it fails specifically on 20.2.0 which is probably just a faulty nodejs release (guessing).

I'll close this issue for now. Cheers!

ingydotnet avatar Sep 15 '25 08:09 ingydotnet

https://www.npmjs.com/package/@yaml/yamlscript/v/0.2.4 is released now.

Let me know if you have any problems with it.

ingydotnet avatar Sep 16 '25 19:09 ingydotnet