windmill-labs/windmill · error

Script snapshot creation was not successful: ${req.status} -

Error message

Script snapshot creation was not successful: ${req.status} - ${req.statusText} - ${await req.text()}

What it means

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.

Source

Thrown at frontend/src/lib/components/Dev.svelte:397

						}
						let blob = new Blob([new Uint8Array(array)], { type: 'application/octet-stream' })

						form.append('file', blob)
					} else {
						form.append('file', file)
					}

					const url = '/api/w/' + workspace + '/jobs/run/preview_bundle'

					const req = await fetch(url, {
						method: 'POST',
						body: form,
						headers: {
							Authorization: 'Bearer ' + token
						}
					})
					if (req.status != 201) {
						throw Error(
							`Script snapshot creation was not successful: ${req.status} - ${
								req.statusText
							} - ${await req.text()}`
						)
					}
					return await req.text()
				} catch (e) {
					sendUserToast(`Failed to send bundle ${e}`, true)
					throw Error(e)
				}
			},
			{
				done(x) {
					loadPastTests()
				}
			}
		)
		loadingCodebaseButton = false

View on GitHub (pinned to e474e8803c)

Solutions

  1. Read the status and body in the error: 401 → re-login; 413 → reduce bundle size; 502 → fix backend port/REMOTE
  2. Re-login to refresh the Bearer token used in the request
  3. Verify the backend is running and the frontend REMOTE points to it
  4. Check the script path/workspace are valid and saved before running a test

Example fix

// diagnose the embedded status
} catch (e) {
  const m = String(e).match(/not successful: (\d+)/);
  if (m?.[1] === '401') await relogin();
  throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight auth + connectivity check
const probe = await fetch(`${backendUrl}/api/workspaces/list`, { headers: { Authorization: `Bearer ${token}` } });
if (probe.status === 401) throw new Error('Session expired — re-login before running tests');

Try / catch

try {
  await runTest();
} catch (e) {
  const status = Number(String(e).match(/not successful: (\d+)/)?.[1]);
  if (status === 401) await reloginAndRetry();
  else if (status >= 500 || status === 0) await retryWithBackoff(runTest);
  else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/914d7be9cf22e4dc. Report an issue: GitHub.