sveltejs / sveltejs/kit

experimental:tracing+async conflicts

Open
#17,004 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

If you activate opentelemetry as described in the docs, and also use the experimental async feature, import-in-the-middle will kick you in the pants during SSR by messing with the mutable let ssr_context.

Reproduction

https://github.com/fredrik-stock/repros/tree/main/ssr-ondestroy-crash

Had a giant convoluted repro, but passing in through an LLM got it down to what I'd call minimal indeed.

Logs
TypeError: Cannot read properties of null (reading 'r').
System Info
System:
    OS: Linux 7.0 Ubuntu 26.04.1 LTS 26.04.1 LTS (Resolute Raccoon)
    CPU: (20) x64 Intel(R) Core(TM) i9-7900X CPU @ 3.30GHz
    Memory: 11.83 GB / 61.24 GB
    Container: Yes
    Shell: 0.115.1 - /home/linuxbrew/.linuxbrew/bin/nu
  Binaries:
    Node: 24.13.0 - /run/user/1000/fnm_multishells/346766_1788353160080/bin/node
    npm: 11.6.2 - /run/user/1000/fnm_multishells/346766_1788353160080/bin/npm
    pnpm: 11.24.0 - /run/user/1000/fnm_multishells/346766_1788353160080/bin/pnpm
    bun: 1.3.14 - /home/fredrik/.local/bin/bun
  Browsers:
    Firefox: 154.0.1
    Firefox Developer Edition: 154.0.1
  npmPackages:
    @sveltejs/adapter-node: catalog: => 5.5.7
    @sveltejs/kit: catalog: => 2.70.3
    @sveltejs/vite-plugin-svelte: catalog: => 7.3.0
    svelte: catalog: => 5.56.10
    vite: catalog: => 8.2.1
Severity

serious, but I can work around it

Additional Information

I didn't keep the stack trace, just fixed it and moved on.

My workaround: register({ shouldInclude: (_url, specifier) => !specifier.startsWith('.') }) instead of a bare register().

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproduction at fredrik-stock/repros/tree/main/ssr-ondestroy-crash and the observability guidance in documentation/docs/30-advanced/68-observability.md. Reproduce the SSR failure with OpenTelemetry enabled alongside the experimental async feature, then trace how import-in-the-middle affects the mutable ssr_context. Done means the combined setup no longer throws the reported TypeError and does not require the documented register workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.