Skip to content

Commit 961ba2c

Browse files
authored
fix: better error message when using read with adapter-auto - closes #11684 (#11689)
Co-authored-by: Rich Harris <[email protected]>
1 parent b3c8a8c commit 961ba2c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.changeset/shy-spiders-remember.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/adapter-auto': patch
3+
---
4+
5+
fix: better error message when using `read`

packages/adapter-auto/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,12 @@ export default () => ({
116116
builder.log.warn(
117117
'Could not detect a supported production environment. See https://kit.svelte.dev/docs/adapters to learn how to configure your app to run on the platform of your choosing'
118118
);
119+
},
120+
supports: {
121+
read: () => {
122+
throw new Error(
123+
"The read function imported from $app/server only works in certain environments. Since you're using @sveltejs/adapter-auto, SvelteKit cannot determine whether it will work when your app is deployed. Please replace it with an adapter tailored to your target environment."
124+
);
125+
}
119126
}
120127
});

0 commit comments

Comments
 (0)