Skip to content

Flag to require that wrapped object has some finalizer#28

Draft
sadhbh-c0d3 wants to merge 2 commits into
mainfrom
snapi-require-finalize-cb
Draft

Flag to require that wrapped object has some finalizer#28
sadhbh-c0d3 wants to merge 2 commits into
mainfrom
snapi-require-finalize-cb

Conversation

@sadhbh-c0d3

@sadhbh-c0d3 sadhbh-c0d3 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

When guest is calling napi_add_finalizer() it expects valid napi_ref returned and not a nullptr. Correct solution would be to wrap callback and data provided by guest into native finalizer closure. We're not doing this here, and we only set Nop callback to avoid crash that would be caused by returnrf nullptr otherwise.

Note While this fixes the below issue, I have doubts that this should be merged. I think correct solution need to be made for this.

This should fix following crash at startup:

Running `target/debug/wasmer run --experimental-napi -l /tmp/edge-wasix/bin/edgejs`
node:internal/modules/run_main:107
    triggerUncaughtException(
    ^

TypeError: Illegal invocation
    at process.startListeningIfSignal (node:internal/process/signal:28:10)
    at process.emit (node:events:520:35)
    at _addListener (node:events:551:14)
    at process.addListener (node:events:600:10)
    at process.getStdout [as stdout] (node:internal/bootstrap/switches/is_main_thread:159:13)
    at console.get (node:internal/console/constructor:221:38)
    at console.value (node:internal/console/constructor:290:39)
    at console.log (node:internal/console/constructor:416:26)
    at node:internal/main/repl:38:13
    at asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:11)

Node.js v24.13.2
[callback trampoline] error calling function: RuntimeError: WASI exited with code: ExitCode::1

@sadhbh-c0d3 sadhbh-c0d3 marked this pull request as draft June 2, 2026 00:07
Comment thread src/guest/napi.rs Outdated
@syrusakbary syrusakbary marked this pull request as ready for review June 12, 2026 19:01
Co-authored-by: Syrus Akbary <me@syrusakbary.com>
@sadhbh-c0d3 sadhbh-c0d3 marked this pull request as draft June 16, 2026 18:40
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

Successfully merging this pull request may close these issues.

2 participants