sveltejs / sveltejs/kit

Error "Could not get the request store" when invoking `*.remote` from helper

Open
#14,523 4 comments 1 reaction 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

I have the following code:

+page.svelte

<script lang="ts">
  import {something} from './something'
</script>

{something}

something.ts

import {getSomething} from './get-something.remote'
export const something = await getSomething()

get-something.remote.ts

import {prerender} from '$app/server'
export const getSomething = prerender(() => 'test')

This leads to an error:

[500] GET /
Error: Could not get the request store. This is an internal error.
    at get_request_store (file:/home/qo5ip4we0aj4vrkeetv8swp3pbyxe1-fmt4/node_modules/@sveltejs/kit/src/exports/internal/event.js:74:9)
    at eval (node_modules/@sveltejs/kit/src/runtime/app/server/remote/prerender.js:96:72)
    at wrapper (node_modules/@sveltejs/kit/src/runtime/app/server/remote/prerender.js:156:5)
    at eval (src/routes/something.ts:6:63)
    at async ESModulesEvaluator.runInlinedModule (file:/home/qo5ip4we0aj4vrkeetv8swp3pbyxe1-fmt4/node_modules/vite/dist/node/module-runner.js:930:3)
    at async SSRCompatModuleRunner.directRequest (file:/home/qo5ip4we0aj4vrkeetv8swp3pbyxe1-fmt4/node_modules/vite/dist/node/module-runner.js:1137:59)
    at async SSRCompatModuleRunner.directRequest (file:/home/qo5ip4we0aj4vrkeetv8swp3pbyxe1-fmt4/node_modules/vite/dist/node/chunks/dep-Bm2ujbhY.js:18727:22)
    at async SSRCompatModuleRunner.cachedRequest (file:/home/qo5ip4we0aj4vrkeetv8swp3pbyxe1-fmt4/node_modules/vite/dist/node/module-runner.js:1055:73)
    at async eval (src/routes/+page.svelte:5:31)
Image

The error does not occur when invoking getSomething directly in the component.

Reproduction

Repro

System Info
Svelte 5.39.5
SvelteKit 2.43.2
Severity

blocking an upgrade

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 runtime/app/server/remote/prerender.js and internal/event.js, especially the stack-trace paths through get_request_store and the prerender wrapper. Run the linked SvelteLab reproduction with the listed SvelteKit and Svelte versions, comparing helper invocation with direct component invocation. Done means the helper case no longer raises the request-store error while direct invocation remains functional.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.