windmill-labs/windmill · warning

Response body is empty

Error message

Response body is empty

What it means

The generated webhook test code checks response.body after the ok check and throws 'Response body is empty' when the streaming body is null. The rest of the snippet streams the body via getReader(), which requires a non-null body, so it fails fast with a clear message.

Source

Thrown at frontend/src/lib/components/triggers/webhook/WebhooksConfigSection.svelte:132

	function fetchCode() {
		if (requestType === 'sync_sse') {
			return `import { EventSource } from "eventsource";

export async function main() {
  const response = await fetch(\`${url}\`, {
    method: '${callMethod === 'get' ? 'GET' : 'POST'}',
    headers: ${JSON.stringify(headers(), null, 2).replaceAll('\n', '\n    ')},
    body: ${callMethod === 'get' ? 'undefined' : `JSON.stringify(${JSON.stringify(cleanedRunnableArgs ?? {}, null, 2).replaceAll('\n', '\n    ')})`}
  });
  
  if (!response.ok) {
	const text = await response.text()
	throw new Error(\`\${response.status} \${text}\`)
  }

  if (!response.body) {
    throw new Error("Response body is empty");
  }

  const reader = response.body.getReader();
  const decoder = new TextDecoder();
  let buffer = "";

  try {
    while (true) {
      const { done, value } = await reader.read();

      if (done) break;

      buffer += decoder.decode(value, { stream: true });
      const lines = buffer.split("\\n");

      // Keep the last incomplete line in buffer
      buffer = lines.pop() || "";

View on GitHub (pinned to e474e8803c)

Solutions

  1. Make the webhook script return a value so the response has a body
  2. Use a method (POST/GET) that yields a payload rather than HEAD/204
  3. Catch this case in the generated code and treat an empty body as a valid no-content response

Example fix

// before
if (!response.body) { throw new Error("Response body is empty"); }
// after
if (!response.body) { console.warn('Empty response body'); return; }
Defensive patterns

Strategy: fallback

Validate before calling

const res = await fetch(url, { method: 'POST' });
if (res.status === 204 || res.headers.get('content-length') === '0') {
  console.warn('Empty body expected');
}

Type guard

function hasReadableBody(res: Response): res is Response & { body: ReadableStream } {
  return res.body !== null;
}

Try / catch

try { await runTest(); } catch (e) {
  if (e.message === 'Response body is empty') { treatAsNoContent(); }
  else throw e;
}

Prevention

When it happens

Trigger: The endpoint returned a successful (ok) response whose body stream is null — e.g. 204 No Content, HEAD request, or an environment/proxy stripping the body.

Common situations: Webhook script returns nothing (empty response) so the platform answers 204; testing with GET on an endpoint that returns no payload; misconfigured handler returning an empty 200.

Related errors


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