sveltejs/kit · error · Error
Cannot call a command (${__.name}) ${violation}
Error message
Cannot call a command (${__.name}) ${violation} What it means
Runtime guard around a remote command invocation: commands are mutative and may only run inside a mutative request (POST/PUT/PATCH/DELETE). The wrapper rejects the call when the request method is non-mutative, or when the call happens inside a remote query/prerender function (which must stay pure). The message states which violation occurred — wrong HTTP method handler or nested in query/prerender.
Source
Thrown at packages/kit/src/runtime/app/server/remote/command.js:78
/** @type {RemoteCommandInternals} */
const __ = { type: 'command', id: '', name: '' };
/** @type {RemoteCommand<Input, Output> & { __: RemoteCommandInternals }} */
const wrapper = (arg) => {
const { event, state } = get_request_store();
if (
!MUTATIVE_METHODS.includes(event.request.method) ||
state.is_in_remote_query ||
state.is_in_remote_prerender
) {
const violation =
state.is_in_remote_query || state.is_in_remote_prerender
? `inside a query or prerender function`
: `from a ${event.request.method} handler`;
throw new Error(`Cannot call a command (${__.name}) ${violation}`);
}
if (state.is_in_render) {
throw new Error(`Cannot call a command (${__.name}) during server-side rendering`);
}
const promise = Promise.resolve(
run_remote_function(event, state, true, () => validate(arg), fn)
);
// @ts-expect-error
promise.updates = () => {
throw new Error(`Cannot call '${__.name}(...).updates(...)' on the server`);
};
return /** @type {ReturnType<RemoteCommand<Input, Output>>} */ (promise);
};
View on GitHub (pinned to 03f1687fe6)
Solutions
- Call the command from a POST/PUT/PATCH/DELETE handler or a form submission, not from a GET
- Move the mutation out of the query/prerender function and into a command invoked by user interaction
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/kit/src/runtime/app/server/remote/command.js:78 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/1b17ee0578e8da22.
Report an issue: GitHub.