{"record":{"id":"1b17ee0578e8da22","repo":"sveltejs/kit","slug":"cannot-call-a-command-name-violation","errorCode":null,"errorMessage":"Cannot call a command (${__.name}) ${violation}","messagePattern":"Cannot call a command \\((.+?)\\) (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/app/server/remote/command.js","lineNumber":78,"sourceCode":"\n\t/** @type {RemoteCommandInternals} */\n\tconst __ = { type: 'command', id: '', name: '' };\n\n\t/** @type {RemoteCommand<Input, Output> & { __: RemoteCommandInternals }} */\n\tconst wrapper = (arg) => {\n\t\tconst { event, state } = get_request_store();\n\n\t\tif (\n\t\t\t!MUTATIVE_METHODS.includes(event.request.method) ||\n\t\t\tstate.is_in_remote_query ||\n\t\t\tstate.is_in_remote_prerender\n\t\t) {\n\t\t\tconst violation =\n\t\t\t\tstate.is_in_remote_query || state.is_in_remote_prerender\n\t\t\t\t\t? `inside a query or prerender function`\n\t\t\t\t\t: `from a ${event.request.method} handler`;\n\n\t\t\tthrow new Error(`Cannot call a command (${__.name}) ${violation}`);\n\t\t}\n\n\t\tif (state.is_in_render) {\n\t\t\tthrow new Error(`Cannot call a command (${__.name}) during server-side rendering`);\n\t\t}\n\n\t\tconst promise = Promise.resolve(\n\t\t\trun_remote_function(event, state, true, () => validate(arg), fn)\n\t\t);\n\n\t\t// @ts-expect-error\n\t\tpromise.updates = () => {\n\t\t\tthrow new Error(`Cannot call '${__.name}(...).updates(...)' on the server`);\n\t\t};\n\n\t\treturn /** @type {ReturnType<RemoteCommand<Input, Output>>} */ (promise);\n\t};\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/app/server/remote/command.js#L60-L96","documentation":"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.","triggerScenarios":"Thrown at packages/kit/src/runtime/app/server/remote/command.js:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}