Skip to content

deno: init() never registers the channel-injection hooks, though Deno supports them #23892

Closed

Description

@isaacs

Deno 2.9.2 has a working Module.registerHooks, and hasStableSyncModuleHooks already returns true for Deno unconditionally (register.ts:20). Calling the register function directly works:

$ deno run -A reg.mjs
marker after register: {"runtime":[]}    # hooks registered

But @sentry/deno's init() never calls it:

$ deno run -A nospans.mjs
orchestrion marker: undefined

Node's init() calls registerDiagnosticsChannelInjection() and then detectOrchestrionSetup(). Deno instead expects the user to remember deno run --import=@sentry/deno/import app.ts, and gives no warning at all if they forget. All 22 channel integrations still install and report Integration installed.

Work item. Call registerDiagnosticsChannelInjection() from @sentry/deno's init() behind the same enableRuntimeChannelInjection option Node uses, and call detectOrchestrionSetup() after client creation. Keep @sentry/deno/import working for the case where modules are imported before init().

**Prior art **(related history only). #21451 (merged) added the @sentry/deno/import runtime hook, and #22790 (merged) raised the floor to Deno >= 2.8.3, which is what makes the Module.registerHooks path safe to call unconditionally. No issue covers calling it from init().

Activity

  1. linear-code commented on Sep 2, 2026

    @linear-code
  2. added
    javascriptPull requests that update javascript code
    on Sep 2, 2026
  3. affanmomin commented on Oct 4, 2026

    @affanmomin

    I tried the straightforward fix for this, and it breaks Deno apps that don't grant env access, so I'd like to check the direction before opening a PR.

    The fix mirrors what NodeClient does: call registerDiagnosticsChannelInjection() in the DenoClient constructor (behind the same __SENTRY_CHANNEL_INJECTION__ / enableRuntimeChannelInjection guards) and detectOrchestrionSetup() at the end of init(). Functionally it works. A scenario that calls init() and then imports mysql, with no --preload, gets the transformed module and __SENTRY_ORCHESTRION__.runtime is ["mysql"]. Before the change it was events= marker=null.

    The catch is the static import of @sentry/server-runtime-injection/register. It pulls in the vendored debug package, which runs Object.keys(process.env) at module evaluation. So packages/deno/test/example.ts, run with only --allow-net, now dies on import:

    error: Uncaught (in promise) NotCapable: Requires env access, run again with the --allow-env flag
    exports.inspectOpts = Object.keys(process.env).filter(key => {
    

    enableRuntimeChannelInjection: false doesn't help, since the crash happens before init() runs. tracing-hooks also reads process.env.TRACING_DUMP while transforming each module, so even without debug the hooks need env access once they are active. I assume this is why Deno currently opts in through --preload.

    Two directions I can see:

    1. Keep --preload=npm:@sentry/deno/import as the supported setup on Deno and make the missing case visible: an always-on warning from init() when channel integrations are installed but neither the runtime nor the bundler marker is set, plus a README section (the README doesn't mention the import hook today). Small and safe.
    2. Make the injection package safe to import without env permission (stop the vendored debug from reading env at load, and guard the TRACING_DUMP reads), then register from init() as Node does. That gives Deno users what this issue asks for, but it touches the shared injection package and changes how its debug logging is enabled on Node.

    I'm happy to send either. Which would you prefer?

  4. chargome commented on Oct 5, 2026

    @chargome
    Member

    Thanks for reaching out, we'll let @isaacs make the call here.

  5. isaacs commented on Oct 17, 2026

    @isaacs
    MemberAuthor

    @affanmomin Sorry for the delay circling back to this! Thanks for laying out the options.

    I'd lean towards option 2. Making the two platforms more consistent with one another is the overarching goal here, and a env-touching debug feels like it's a bit unnecessary anyway.

    If you've moved onto other things, no worries. I'll put it on my list to pick it up in the next few days if you don't. 👍

  6. added a commit that references this issue on Oct 21, 2026
    ca4fc32
  7. github-actions commented on Oct 23, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #25546, which was included in the 11.9.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugDenojavascriptPull requests that update javascript code

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions