tweak error codes to better align with existing conventions, such as they are

pull/16748/head
Rich Harris 1 week ago
parent d68f89e98c
commit ec82e9bf6a

@ -1,6 +1,6 @@
<!-- This file is generated by scripts/process-messages/index.js. Do not edit! --> <!-- This file is generated by scripts/process-messages/index.js. Do not edit! -->
### async_in_sync ### await_invalid
``` ```
Encountered asynchronous work while rendering synchronously. 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. 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.

@ -1,10 +1,10 @@
## async_in_sync ## await_invalid
> Encountered asynchronous work while rendering synchronously. > 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. 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 > Attempted to use `renderAsync` without `experimental.async` enabled

@ -6,8 +6,8 @@ export * from '../shared/errors.js';
* Encountered asynchronous work while rendering synchronously. * Encountered asynchronous work while rendering synchronously.
* @returns {never} * @returns {never}
*/ */
export function async_in_sync() { export function await_invalid() {
const error = new Error(`async_in_sync\nEncountered asynchronous work while rendering synchronously.\nhttps://svelte.dev/e/async_in_sync`); const error = new Error(`await_invalid\nEncountered asynchronous work while rendering synchronously.\nhttps://svelte.dev/e/await_invalid`);
error.name = 'Svelte error'; error.name = 'Svelte error';
@ -18,8 +18,8 @@ export function async_in_sync() {
* Attempted to use `renderAsync` without `experimental.async` enabled * Attempted to use `renderAsync` without `experimental.async` enabled
* @returns {never} * @returns {never}
*/ */
export function missing_experimental_flag() { export function experimental_async_ssr() {
const error = new Error(`missing_experimental_flag\nAttempted to use \`renderAsync\` without \`experimental.async\` enabled\nhttps://svelte.dev/e/missing_experimental_flag`); 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'; error.name = 'Svelte error';

@ -119,7 +119,7 @@ export function render(component, options = {}) {
*/ */
export async function render_async(component, options = {}) { export async function render_async(component, options = {}) {
if (!async_mode_flag) { if (!async_mode_flag) {
e.missing_experimental_flag(); e.experimental_async_ssr();
} }
var previous_context = ssr_context; var previous_context = ssr_context;

@ -283,7 +283,7 @@ export class Payload {
const result = render(child_payload); const result = render(child_payload);
if (result instanceof Promise) { if (result instanceof Promise) {
if (this.global.mode === 'sync') { 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 // just to avoid unhandled promise rejections -- we'll end up throwing in `collect_async` if something fails
result.catch(() => {}); result.catch(() => {});

@ -70,7 +70,7 @@ test('creating an async child in a sync context throws', () => {
await Promise.resolve(); await Promise.resolve();
$$payload.push('x'); $$payload.push('x');
}) })
).toThrow('async_in_sync'); ).toThrow('await_invalid');
}); });
test('collect_async allows awaiting payload to get aggregated content', async () => { test('collect_async allows awaiting payload to get aggregated content', async () => {

@ -3,5 +3,5 @@ import { test } from '../../test';
export default test({ export default test({
mode: ['server'], mode: ['server'],
error: 'async_in_sync' error: 'await_invalid'
}); });

Loading…
Cancel
Save