Skip to content

Can't use read at the top-level in remote function files. #14671

@teemingc

Description

@teemingc

Describe the bug

We probably need to initialise the read implementation and other things more similarly to how we do it before we analyse the server files in packages/kit/src/core/postbuild/analyse.js. Currently, we only initialise env and even that was fixed just recently.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-c7u1ifwk?file=src%2Froutes%2Fexample.remote.js

Try running npm run build and see the build fail because of the top-level read function call in the remote function file.

Logs

Error: No `read` implementation was provided. Please ensure that your adapter is up to date and supports this feature
    at Module.read (file:///home/projects/sveltejs-kit-template-default-c7u1ifwk/.svelte-kit/output/server/chunks/_page.js:30:11)
    at eval (file:///home/projects/sveltejs-kit-template-default-c7u1ifwk/.svelte-kit/output/server/chunks/remote-2b61k.js:30:25)
    at _0x370799 (https://sveltejskittemplatedefaultc7u1-41xc.w-credentialless-staticblitz.com/blitz.96435430.js:31:827521)
    at _0x2193bc.run (https://sveltejskittemplatedefaultc7u1-41xc.w-credentialless-staticblitz.com/blitz.96435430.js:31:828286)
    at _0x1b2515 (https://sveltejskittemplatedefaultc7u1-41xc.w-credentialless-staticblitz.com/blitz.96435430.js:31:843394)
    at _0x47c9a5._evaluate (https://sveltejskittemplatedefaultc7u1-41xc.w-credentialless-staticblitz.com/blitz.96435430.js:31:843723)
    at _0x47c9a5.evaluate (https://sveltejskittemplatedefaultc7u1-41xc.w-credentialless-staticblitz.com/blitz.96435430.js:31:840218)
    at ModuleJob.run (node:internal/modules/esm/module_job:158:3371)
    at async ModuleLoader.import (node:internal/modules/esm/loader:157:5061)

Node.js v20.19.1
 ELIFECYCLE  Command failed with exit code 1.

System Info

stackblitz

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions