Describe the bug
Previously, the sequence() generated handle could be called from a test to simulate request handling. When upgrading to the latest SvelteKit version, this now raises an error: Could not get the request store. This is an internal error. It appears this is due to missing state expected by the new OpenTelemetry Tracing feature.
I am not aware of any other way of directly testing server hooks then by invoking them directly in a test. The only work around I found is by mocking the sequence helper in the test fixture.
Reproduction
This reproduction demonstrates the error:
sveltekit-issue-get-request-store
The repository also includes a working test, using SveltKit v2.21.2.
Logs
FAIL server src/hooks.server.test.ts > can call handler
Error: Could not get the request store. This is an internal error.
❯ get_request_store node_modules/@sveltejs/kit/src/exports/internal/event.js:48:9
❯ node_modules/@sveltejs/kit/src/exports/hooks/sequence.js:85:21
❯ src/hooks.server.test.ts:12:26
10| } as RequestEvent
11| const resolve = vi.fn().mockResolvedValue(new Response('OK'));
12| const response = await handle({ event : event, resolve : resolve });
| ^
13| expect(response).toBeDefined();
14| });
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files 1 failed (1)
Tests 1 failed (1)
Start at 11:37:10
Duration 488ms (transform 53ms, setup 0ms, collect 67ms, tests 8ms, environment 0ms, prepare 127ms)
System Info
System:
OS: Windows 11 10.0.26100
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 1.67 GB / 11.70 GB
Binaries:
Node: 22.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 4.9.2 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Chromium (138.0.3351.77)
Internet Explorer: 11.0.26100.1882
npmPackages:
@sveltejs/adapter-auto: ^6.0.0 => 6.0.1
@sveltejs/kit: ^2.31.1 => 2.21.2
@sveltejs/vite-plugin-svelte: ^5.0.0 => 5.1.0
svelte: ^5.0.0 => 5.33.18
vite: ^6.2.6 => 6.3.5
Severity
annoyance
Additional Information
No response
Describe the bug
Previously, the
sequence()generated handle could be called from a test to simulate request handling. When upgrading to the latest SvelteKit version, this now raises an error:Could not get the request store. This is an internal error.It appears this is due to missingstateexpected by the newOpenTelemetry Tracingfeature.I am not aware of any other way of directly testing server hooks then by invoking them directly in a test. The only work around I found is by mocking the
sequencehelper in the test fixture.Reproduction
This reproduction demonstrates the error:
sveltekit-issue-get-request-store
The repository also includes a working test, using SveltKit v2.21.2.
Logs
System Info
System: OS: Windows 11 10.0.26100 CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz Memory: 1.67 GB / 11.70 GB Binaries: Node: 22.16.0 - C:\Program Files\nodejs\node.EXE Yarn: 4.9.2 - ~\AppData\Roaming\npm\yarn.CMD npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Chromium (138.0.3351.77) Internet Explorer: 11.0.26100.1882 npmPackages: @sveltejs/adapter-auto: ^6.0.0 => 6.0.1 @sveltejs/kit: ^2.31.1 => 2.21.2 @sveltejs/vite-plugin-svelte: ^5.0.0 => 5.1.0 svelte: ^5.0.0 => 5.33.18 vite: ^6.2.6 => 6.3.5Severity
annoyance
Additional Information
No response