{"record":{"id":"0d2e09c228f86538","repo":"sveltejs/kit","slug":"cannot-call-a-command-name-during-server-s","errorCode":null,"errorMessage":"Cannot call a command (${__.name}) during server-side rendering","messagePattern":"Cannot call a command \\((.+?)\\) during server-side rendering","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/app/server/remote/command.js","lineNumber":82,"sourceCode":"\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\n\tObject.defineProperty(wrapper, '__', { value: __ });\n\n\t// On the server, pending is always 0\n\tObject.defineProperty(wrapper, 'pending', {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/app/server/remote/command.js#L64-L100","documentation":"Runtime guard around a remote command: the request-store state marks the current execution as server-side rendering (is_in_render). Commands mutate state and require a real mutative request, so invoking one during SSR (e.g. at component init while rendering) is rejected.","triggerScenarios":"Thrown at packages/kit/src/runtime/app/server/remote/command.js:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the command call into a user-triggered event handler (form submit, button click) or a load/query function","Avoid invoking commands during component initialization on the server"],"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"}