diff --git a/documentation/docs/98-reference/.generated/server-errors.md b/documentation/docs/98-reference/.generated/server-errors.md index e56886b603..037a3dafd9 100644 --- a/documentation/docs/98-reference/.generated/server-errors.md +++ b/documentation/docs/98-reference/.generated/server-errors.md @@ -1,6 +1,6 @@ -### async_in_sync +### await_invalid ``` Encountered asynchronous work while rendering synchronously. @@ -8,18 +8,18 @@ Encountered asynchronous work while rendering synchronously. You (or the framework you're using) used `render` with an async component. Either use `renderAsync` or wrap the async component in a `svelte:boundary` with a `pending` snippet. -### lifecycle_function_unavailable +### experimental_async_ssr ``` -`%name%(...)` is not available on the server +Attempted to use `renderAsync` without `experimental.async` enabled ``` -Certain methods such as `mount` cannot be invoked while running in a server context. Avoid calling them eagerly, i.e. not during render. +Set `experimental.async: true` in your compiler options to use async server rendering. -### missing_experimental_flag +### lifecycle_function_unavailable ``` -Attempted to use `renderAsync` without `experimental.async` enabled +`%name%(...)` is not available on the server ``` -Set `experimental.async: true` in your compiler options to use async server rendering. +Certain methods such as `mount` cannot be invoked while running in a server context. Avoid calling them eagerly, i.e. not during render. diff --git a/packages/svelte/messages/server-errors/async.md b/packages/svelte/messages/server-errors/async.md index 164c77f943..69f381f480 100644 --- a/packages/svelte/messages/server-errors/async.md +++ b/packages/svelte/messages/server-errors/async.md @@ -1,10 +1,10 @@ -## async_in_sync +## await_invalid > Encountered asynchronous work while rendering synchronously. You (or the framework you're using) used `render` with an async component. Either use `renderAsync` or wrap the async component in a `svelte:boundary` with a `pending` snippet. -## missing_experimental_flag +## experimental_async_ssr > Attempted to use `renderAsync` without `experimental.async` enabled diff --git a/packages/svelte/src/internal/server/errors.js b/packages/svelte/src/internal/server/errors.js index 79211e7054..792409da76 100644 --- a/packages/svelte/src/internal/server/errors.js +++ b/packages/svelte/src/internal/server/errors.js @@ -6,8 +6,8 @@ export * from '../shared/errors.js'; * Encountered asynchronous work while rendering synchronously. * @returns {never} */ -export function async_in_sync() { - const error = new Error(`async_in_sync\nEncountered asynchronous work while rendering synchronously.\nhttps://svelte.dev/e/async_in_sync`); +export function await_invalid() { + const error = new Error(`await_invalid\nEncountered asynchronous work while rendering synchronously.\nhttps://svelte.dev/e/await_invalid`); error.name = 'Svelte error'; @@ -18,8 +18,8 @@ export function async_in_sync() { * Attempted to use `renderAsync` without `experimental.async` enabled * @returns {never} */ -export function missing_experimental_flag() { - const error = new Error(`missing_experimental_flag\nAttempted to use \`renderAsync\` without \`experimental.async\` enabled\nhttps://svelte.dev/e/missing_experimental_flag`); +export function experimental_async_ssr() { + const error = new Error(`experimental_async_ssr\nAttempted to use \`renderAsync\` without \`experimental.async\` enabled\nhttps://svelte.dev/e/experimental_async_ssr`); error.name = 'Svelte error'; diff --git a/packages/svelte/src/internal/server/index.js b/packages/svelte/src/internal/server/index.js index f1b6dbf970..584a5713aa 100644 --- a/packages/svelte/src/internal/server/index.js +++ b/packages/svelte/src/internal/server/index.js @@ -119,7 +119,7 @@ export function render(component, options = {}) { */ export async function render_async(component, options = {}) { if (!async_mode_flag) { - e.missing_experimental_flag(); + e.experimental_async_ssr(); } var previous_context = ssr_context; diff --git a/packages/svelte/src/internal/server/payload.js b/packages/svelte/src/internal/server/payload.js index a6e1045bf2..f786e450f4 100644 --- a/packages/svelte/src/internal/server/payload.js +++ b/packages/svelte/src/internal/server/payload.js @@ -283,7 +283,7 @@ export class Payload { const result = render(child_payload); if (result instanceof Promise) { if (this.global.mode === 'sync') { - e.async_in_sync(); + e.await_invalid(); } // just to avoid unhandled promise rejections -- we'll end up throwing in `collect_async` if something fails result.catch(() => {}); diff --git a/packages/svelte/src/internal/server/payload.test.ts b/packages/svelte/src/internal/server/payload.test.ts index dfba397021..29e86262ba 100644 --- a/packages/svelte/src/internal/server/payload.test.ts +++ b/packages/svelte/src/internal/server/payload.test.ts @@ -70,7 +70,7 @@ test('creating an async child in a sync context throws', () => { await Promise.resolve(); $$payload.push('x'); }) - ).toThrow('async_in_sync'); + ).toThrow('await_invalid'); }); test('collect_async allows awaiting payload to get aggregated content', async () => { diff --git a/packages/svelte/tests/runtime-runes/samples/async-no-pending-throws-sync/_config.js b/packages/svelte/tests/runtime-runes/samples/async-no-pending-throws-sync/_config.js index 78e772cd70..366477d197 100644 --- a/packages/svelte/tests/runtime-runes/samples/async-no-pending-throws-sync/_config.js +++ b/packages/svelte/tests/runtime-runes/samples/async-no-pending-throws-sync/_config.js @@ -3,5 +3,5 @@ import { test } from '../../test'; export default test({ mode: ['server'], - error: 'async_in_sync' + error: 'await_invalid' });