{"record":{"id":"914d7be9cf22e4dc","repo":"windmill-labs/windmill","slug":"script-snapshot-creation-was-not-successful-req-914d7b","errorCode":null,"errorMessage":"Script snapshot creation was not successful: ${req.status} - ${req.statusText} - ${await req.text()}","messagePattern":"Script snapshot creation was not successful: (.+?) - (.+?) - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/Dev.svelte","lineNumber":397,"sourceCode":"\t\t\t\t\t\t}\n\t\t\t\t\t\tlet blob = new Blob([new Uint8Array(array)], { type: 'application/octet-stream' })\n\n\t\t\t\t\t\tform.append('file', blob)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tform.append('file', file)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst url = '/api/w/' + workspace + '/jobs/run/preview_bundle'\n\n\t\t\t\t\tconst req = await fetch(url, {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tbody: form,\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\tAuthorization: 'Bearer ' + token\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\tif (req.status != 201) {\n\t\t\t\t\t\tthrow Error(\n\t\t\t\t\t\t\t`Script snapshot creation was not successful: ${req.status} - ${\n\t\t\t\t\t\t\t\treq.statusText\n\t\t\t\t\t\t\t} - ${await req.text()}`\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn await req.text()\n\t\t\t\t} catch (e) {\n\t\t\t\t\tsendUserToast(`Failed to send bundle ${e}`, true)\n\t\t\t\t\tthrow Error(e)\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tdone(x) {\n\t\t\t\t\tloadPastTests()\n\t\t\t\t}\n\t\t\t}\n\t\t)\n\t\tloadingCodebaseButton = false","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/Dev.svelte#L379-L415","documentation":"In the dev/test panel (Dev.svelte `testBundle`), the built bundle is uploaded to create a script snapshot via a raw fetch. Any non-201 response (auth failure, payload too large, server error, backend down) triggers this error containing status, statusText and the response body.","triggerScenarios":"The POST that creates a script snapshot for running a test returns a status other than 201 — e.g. 401 with an expired token, 422 from backend validation, 413 oversized bundle, or 502 because the frontend proxy points at a dead backend.","commonSituations":"Session token expired during a long dev session, running the frontend with a REMOTE mismatch, backend rebuilt without the workspace/script existing yet, or a syntax/size problem in the generated bundle.","solutions":["Read the status and body in the error: 401 → re-login; 413 → reduce bundle size; 502 → fix backend port/REMOTE","Re-login to refresh the Bearer token used in the request","Verify the backend is running and the frontend REMOTE points to it","Check the script path/workspace are valid and saved before running a test"],"exampleFix":"// diagnose the embedded status\n} catch (e) {\n  const m = String(e).match(/not successful: (\\d+)/);\n  if (m?.[1] === '401') await relogin();\n  throw e;\n}","handlingStrategy":"retry","validationCode":"// pre-flight auth + connectivity check\nconst probe = await fetch(`${backendUrl}/api/workspaces/list`, { headers: { Authorization: `Bearer ${token}` } });\nif (probe.status === 401) throw new Error('Session expired — re-login before running tests');","typeGuard":null,"tryCatchPattern":"try {\n  await runTest();\n} catch (e) {\n  const status = Number(String(e).match(/not successful: (\\d+)/)?.[1]);\n  if (status === 401) await reloginAndRetry();\n  else if (status >= 500 || status === 0) await retryWithBackoff(runTest);\n  else throw e;\n}","preventionTips":["Re-login when dev sessions run long (token expiry)","Keep the frontend REMOTE aligned with the live backend port","Keep test bundles small to avoid 413s","Save the script and confirm the workspace before running tests"],"tags":["http","network","dev-tools","bundle"],"backgroundTag":"http-request-failed","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}