Skip to content

module_init installs a global tracing subscriber with init(), which panics or takes over the host's subscriber when embedded #805

Description

@fengmk2

init() runs as the addon's module_init and installs a global tracing subscriber with SubscriberInitExt::init() (src/lib.rs#L361-L379). init() panics if a global subscriber is already installed.

This runs on every load, including when oxc-node's crate is linked into another Node-API addon that sets up its own tracing. Vite+ does this: its binding installs a subscriber for its VP_LOG variable with try_init(). Depending on which runs first:

  • if the host's subscriber is installed first, oxc-node's module_init panics while the addon loads;
  • if oxc-node's runs first, it becomes the global default, so the host's try_init() does nothing: the host's events are filtered by OXC_LOG, and dropped entirely when OXC_LOG is unset.

Proposal

Any one of these lets a host keep its subscriber:

  • use try_init() and ignore the error;
  • install the subscriber only when OXC_LOG is set;
  • gate the module_init registration behind a default-on feature that embedders can turn off.

try_init() is the smallest change and keeps today's behavior for @oxc-node/core.

Today Vite+ removes the module_init attribute in a patch.

Activity

  1. added a commit that references this issue on Oct 9, 2026
    c1400e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions