{"record":{"id":"b420fd22c0e4e731","repo":"remotion-dev/remotion","slug":"restartstudio-is-not-supported-in-browser-studio","errorCode":null,"errorMessage":"restartStudio() is not supported in Browser Studio","messagePattern":"restartStudio\\(\\) is not supported in Browser Studio","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/studio/src/api/restart-studio.ts","lineNumber":17,"sourceCode":"/**\n * @description Restarts the Remotion Studio.\n * @see [Documentation](https://www.remotion.dev/docs/studio/restart-studio)\n */\n\nimport type {RestartStudioResponse} from '@remotion/studio-shared';\nimport {getRemotionEnvironment} from 'remotion';\nimport {callApi} from '../components/call-api';\nimport {getBrowserStudioOperations} from '../helpers/browser-studio-operations';\n\nexport const restartStudio = (): Promise<RestartStudioResponse> => {\n\tif (!getRemotionEnvironment().isStudio) {\n\t\tthrow new Error('restartStudio() is only available in the Studio');\n\t}\n\n\tif (getBrowserStudioOperations() !== null) {\n\t\tthrow new Error('restartStudio() is not supported in Browser Studio');\n\t}\n\n\tif (window.remotion_isReadOnlyStudio) {\n\t\tthrow new Error('restartStudio() is not available in read-only Studio');\n\t}\n\n\treturn callApi('/api/restart-studio', {});\n};\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/remotion-dev/remotion/blob/10db9de07356446fb0edb3c3ae211369b693d18b/packages/studio/src/api/restart-studio.ts#L1-L26","documentation":"`restartStudio()` from `@remotion/studio` restarts the Node-based Remotion Studio by POSTing to `/api/restart-studio`. Browser Studio (the fully in-browser Studio host, detected via `window.remotion_browserStudio`, set through the 'remotion-browser-studio-operations-ready' handshake) has no Node server to restart, so the function throws before making any request. The error means the call is valid only in the desktop/dev-server Studio.","triggerScenarios":"Calling `restartStudio()` (e.g. from a Studio menu item, custom UI `onClick`, or a hotkey handler) while Studio is embedded in Browser Studio, where `getBrowserStudioOperations()` returns a non-null `window.remotion_browserStudio`. The guard at packages/studio/src/api/restart-studio.ts:16 fires before the `/api/restart-studio` API call.","commonSituations":"Studio code shared between the regular dev-server Studio and Browser Studio (e.g. remotion.dev embedded Studio or the `browser-studio` package host); clicking a 'Restart Studio' button or programmatically restarting after a config change in that hosted environment; version mismatches where the host page always injects `remotion_browserStudio`.","solutions":["Do not call `restartStudio()` in hosted/browser contexts: guard with `getRemotionEnvironment().isStudio` plus a check that `(window as any).remotion_browserStudio` is null.","In Browser Studio, trigger a restart by reloading the host page or using the host-provided restart mechanism instead of this API.","If you need server-restart behavior, run the standard Studio locally with `npx remotion studio` and invoke `restartStudio()` there."],"exampleFix":"// before\nimport {restartStudio} from '@remotion/studio';\nawait restartStudio(); // throws in Browser Studio\n\n// after\nimport {getRemotionEnvironment} from 'remotion';\nimport {restartStudio} from '@remotion/studio';\n\nconst w = window as unknown as {remotion_browserStudio?: unknown};\nif (getRemotionEnvironment().isStudio && w.remotion_browserStudio == null) {\n  await restartStudio();\n} else {\n  window.location.reload(); // browser-safe restart\n}","handlingStrategy":"type-guard","validationCode":"import {getRemotionEnvironment} from 'remotion';\n\nconst w = window as unknown as {remotion_browserStudio?: unknown; remotion_isReadOnlyStudio?: boolean};\nconst canRestart =\n  getRemotionEnvironment().isStudio &&\n  w.remotion_browserStudio == null &&\n  !w.remotion_isReadOnlyStudio;\n\nif (canRestart) {\n  const {restartStudio} = await import('@remotion/studio');\n  await restartStudio();\n}","typeGuard":"import {getRemotionEnvironment} from 'remotion';\n\nconst isRestartableStudio = (): boolean =>\n  getRemotionEnvironment().isStudio &&\n  (window as unknown as {remotion_browserStudio?: unknown}).remotion_browserStudio == null &&\n  !(window as unknown as {remotion_isReadOnlyStudio?: boolean}).remotion_isReadOnlyStudio;","tryCatchPattern":"try {\n  await restartStudio();\n} catch (err) {\n  if (err instanceof Error && err.message.includes('not supported in Browser Studio')) {\n    window.location.reload(); // graceful degradation in hosted Studio\n  } else {\n    throw err;\n  }\n}","preventionTips":["Feature-gate restart buttons/UI on `isRestartableStudio()` instead of `getRemotionEnvironment().isStudio` alone.","Remember `restartStudio()` only exists in the dev-server Studio; Browser Studio and read-only deployments always reject it.","In shared Studio extensions, treat restart as best-effort: guard, then fall back to a page reload."],"tags":["studio","browser-studio","restart","environment"],"backgroundTag":"feature-unsupported-in-environment","analyzedSha":"10db9de07356446fb0edb3c3ae211369b693d18b","analyzedAt":"2026-08-22T21:45:17.748Z","contentChangedAt":"2026-08-22T21:45:17.748Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}