Skip to content

fix(napi): support ZeroMQ libuv addon symbols#34657

Merged
littledivy merged 10 commits into
mainfrom
orch/divybot-391
Jun 2, 2026
Merged

fix(napi): support ZeroMQ libuv addon symbols#34657
littledivy merged 10 commits into
mainfrom
orch/divybot-391

Conversation

@divybot

@divybot divybot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Closes #28621
Closes denoland/divybot#391

Fixes loading [email protected] by exporting the libuv/N-API compatibility shims its native addon links against.

This adds support for the missing libuv helpers used during ZeroMQ socket initialization:

  • uv_check_*, uv_idle_*, and uv_poll_*
  • uv_queue_work
  • uv_os_getpid
  • working uv_ref / uv_unref / uv_has_ref behavior for shimmed handles

It also allows napi_new_instance native constructors to call back into JavaScript, which ZeroMQ does via Object.seal(this) while constructing its context/socket objects.

Verification:

  • Repro with import { Subscriber } from "npm:[email protected]" now prints Subscriber and exits.
  • Added N-API coverage for the new libuv loop helpers and JS calls from native constructors.
  • CI is green on the PR head.

@littledivy littledivy changed the title [denoland/deno#28621] Issues with running ZeroMQ fix(napi): add libuv helpers for native addons Jun 1, 2026
@littledivy

Copy link
Copy Markdown
Member

Does this fix #28621?

@divybot

divybot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Yes, this is intended to fix #28621. The ZeroMQ addon failed during native addon loading because Deno did not export libuv symbols that zeromq links against, starting with uv_unref. This PR adds the missing libuv/N-API compatibility shims used by zeromq native addon initialization and covers them with N-API tests.

@littledivy

Copy link
Copy Markdown
Member

Intended to fix? Did you run the repro and it worked?

@divybot

divybot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

I reran the repro after the latest fix. It now works for the reported path:

import { Subscriber } from "npm:[email protected]";

const socket = new Subscriber();
console.log(socket.constructor.name);
socket.close();

Command used against target/debug/deno:

timeout 20s target/debug/deno run --allow-read --allow-env --allow-ffi --allow-run main.ts

Output:

Subscriber

Before the latest commit the original uv_unref lookup was gone, but the addon still failed later during initialization because napi_new_instance disallowed JS in native constructors (zeromq calls Object.seal(this)) and because uv_unref did not actually unref shimmed handles, keeping the process alive. Both are covered now.

@littledivy

Copy link
Copy Markdown
Member

Update PR desc and title to be more specific

@divybot divybot changed the title fix(napi): add libuv helpers for native addons fix(napi): support ZeroMQ libuv addon symbols Jun 2, 2026
Co-Authored-By: Divy Srivastava <[email protected]>
@littledivy
littledivy merged commit b0cc911 into main Jun 2, 2026
136 checks passed
@littledivy
littledivy deleted the orch/divybot-391 branch June 2, 2026 09:50
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.

Issues with running ZeroMQ

2 participants