pull/17124/head
Elliott Johnson 2 weeks ago
parent d5fef8b830
commit 551572ef4b

@ -140,6 +140,12 @@ The `flushSync()` function can be used to flush any pending effects synchronousl
This restriction only applies when using the `experimental.async` option, which will be active by default in Svelte 6.
### fn_unavailable_on_client
```
`%name%`(...) is unavailable on the client.
```
### fork_discarded
```

@ -8,6 +8,12 @@ Encountered asynchronous work while rendering synchronously.
You (or the framework you're using) called [`render(...)`](svelte-server#render) with a component containing an `await` expression. Either `await` the result of `render` or wrap the `await` (or the component containing it) in a [`<svelte:boundary>`](svelte-boundary) with a `pending` snippet.
### fn_unavailable_on_server
```
`%name%`(...) is unavailable on the server.
```
### html_deprecated
```
@ -37,6 +43,13 @@ This error occurs when using `hydratable` or `setHydratableValue` multiple times
</script>
```
### lifecycle_function_unavailable
```
`%name%(...)` is not available on the server
Certain methods such as `mount` cannot be invoked while running in a server context. Avoid calling them eagerly, i.e. not during render.
```
### render_context_unavailable
```

@ -42,14 +42,6 @@ Here, `List.svelte` is using `{@render children(item)` which means it expects `P
A snippet function was passed invalid arguments. Snippets should only be instantiated via `{@render ...}`
```
### lifecycle_function_unavailable
```
`%name%(...)` is not available on the %location%
```
Certain methods such as `mount` cannot be invoked while running in a server context, while others, such as `hydratable.set`, cannot be invoked while running in the browser.
### lifecycle_outside_component
```

@ -108,6 +108,10 @@ The `flushSync()` function can be used to flush any pending effects synchronousl
This restriction only applies when using the `experimental.async` option, which will be active by default in Svelte 6.
## fn_unavailable_on_client
> `%name%`(...) is unavailable on the client.
## fork_discarded
> Cannot commit a fork that was already discarded

@ -4,6 +4,10 @@
You (or the framework you're using) called [`render(...)`](svelte-server#render) with a component containing an `await` expression. Either `await` the result of `render` or wrap the `await` (or the component containing it) in a [`<svelte:boundary>`](svelte-boundary) with a `pending` snippet.
## fn_unavailable_on_server
> `%name%`(...) is unavailable on the server.
## html_deprecated
> The `html` property of server render results has been deprecated. Use `body` instead.
@ -29,6 +33,11 @@ This error occurs when using `hydratable` or `setHydratableValue` multiple times
</script>
```
## lifecycle_function_unavailable
> `%name%(...)` is not available on the server
Certain methods such as `mount` cannot be invoked while running in a server context. Avoid calling them eagerly, i.e. not during render.
## render_context_unavailable
> Failed to retrieve `render` context. %addendum%

@ -34,12 +34,6 @@ Here, `List.svelte` is using `{@render children(item)` which means it expects `P
> A snippet function was passed invalid arguments. Snippets should only be instantiated via `{@render ...}`
## lifecycle_function_unavailable
> `%name%(...)` is not available on the %location%
Certain methods such as `mount` cannot be invoked while running in a server context, while others, such as `hydratable.set`, cannot be invoked while running in the browser.
## lifecycle_outside_component
> `%name%(...)` can only be used during component initialisation

@ -22,19 +22,19 @@ export function createEventDispatcher() {
}
export function mount() {
e.lifecycle_function_unavailable('mount', 'server');
e.lifecycle_function_unavailable('mount');
}
export function hydrate() {
e.lifecycle_function_unavailable('hydrate', 'server');
e.lifecycle_function_unavailable('hydrate');
}
export function unmount() {
e.lifecycle_function_unavailable('unmount', 'server');
e.lifecycle_function_unavailable('unmount');
}
export function fork() {
e.lifecycle_function_unavailable('fork', 'server');
e.lifecycle_function_unavailable('fork');
}
export async function tick() {}

@ -245,6 +245,23 @@ export function flush_sync_in_effect() {
}
}
/**
* `%name%`(...) is unavailable on the client.
* @param {string} name
* @returns {never}
*/
export function fn_unavailable_on_client(name) {
if (DEV) {
const error = new Error(`fn_unavailable_on_client\n\`${name}\`(...) is unavailable on the client.\nhttps://svelte.dev/e/fn_unavailable_on_client`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/fn_unavailable_on_client`);
}
}
/**
* Cannot commit a fork that was already discarded
* @returns {never}

@ -30,7 +30,7 @@ function isomorphic_hydratable(key, fn, options) {
isomorphic_hydratable['get'] = get_hydratable_value;
isomorphic_hydratable['has'] = has_hydratable_value;
isomorphic_hydratable['set'] = () => e.lifecycle_function_unavailable('hydratable.set', 'browser');
isomorphic_hydratable['set'] = () => e.fn_unavailable_on_client('hydratable.set');
/** @type {Hydratable} */
const hydratable = isomorphic_hydratable;

@ -14,6 +14,19 @@ export function await_invalid() {
throw error;
}
/**
* `%name%`(...) is unavailable on the server.
* @param {string} name
* @returns {never}
*/
export function fn_unavailable_on_server(name) {
const error = new Error(`fn_unavailable_on_server\n\`${name}\`(...) is unavailable on the server.\nhttps://svelte.dev/e/fn_unavailable_on_server`);
error.name = 'Svelte error';
throw error;
}
/**
* The `html` property of server render results has been deprecated. Use `body` instead.
* @returns {never}
@ -46,6 +59,21 @@ ${stack}\nhttps://svelte.dev/e/hydratable_clobbering`);
throw error;
}
/**
* `%name%(...)` is not available on the server
* Certain methods such as `mount` cannot be invoked while running in a server context. Avoid calling them eagerly, i.e. not during render.
* @param {string} name
* @returns {never}
*/
export function lifecycle_function_unavailable(name) {
const error = new Error(`lifecycle_function_unavailable\n\`${name}(...)\` is not available on the server
Certain methods such as \`mount\` cannot be invoked while running in a server context. Avoid calling them eagerly, i.e. not during render.\nhttps://svelte.dev/e/lifecycle_function_unavailable`);
error.name = 'Svelte error';
throw error;
}
/**
* Failed to retrieve `render` context. %addendum%
* @param {string} addendum

@ -29,7 +29,7 @@ function isomorphic_hydratable(key, fn, options) {
return entry.value;
}
isomorphic_hydratable['get'] = () => e.lifecycle_function_unavailable('hydratable.get', 'server');
isomorphic_hydratable['get'] = () => e.fn_unavailable_on_server('hydratable.get');
isomorphic_hydratable['has'] = has_hydratable_value;
isomorphic_hydratable['set'] = set_hydratable_value;

@ -51,24 +51,6 @@ export function invalid_snippet_arguments() {
}
}
/**
* `%name%(...)` is not available on the %location%
* @param {string} name
* @param {string} location
* @returns {never}
*/
export function lifecycle_function_unavailable(name, location) {
if (DEV) {
const error = new Error(`lifecycle_function_unavailable\n\`${name}(...)\` is not available on the ${location}\nhttps://svelte.dev/e/lifecycle_function_unavailable`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/lifecycle_function_unavailable`);
}
}
/**
* `%name%(...)` can only be used during component initialisation
* @param {string} name

Loading…
Cancel
Save