Wei-Shaw/sub2api · error

No response body

Error message

No response body

What it means

In frontend/src/components/account/AccountTestModal.vue:445, after response.ok passes, the code calls response.body?.getReader(). response.body is null when the response has no body (204/304) or when the browser does not expose a ReadableStream body (very old browsers, some WebViews). Since this endpoint streams NDJSON, a missing body means streaming is impossible, so the code throws 'No response body'.

Source

Thrown at frontend/src/components/account/AccountTestModal.vue:445

      headers: {
        Authorization: `Bearer ${localStorage.getItem('auth_token')}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        model_id: selectedModelId.value,
        prompt: supportsImageTest.value ? testPrompt.value.trim() : '',
        mode: isOpenAIAccount.value ? testMode.value : 'default'
      }),
      signal: abortController.signal
    })

    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`)
    }

    const reader = response.body?.getReader()
    if (!reader) {
      throw new Error('No response body')
    }

    const decoder = new TextDecoder()
    let buffer = ''

    while (true) {
      const { done, value } = await reader.read()
      if (done) break

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

      for (const line of lines) {
        if (line.startsWith('data: ')) {
          const jsonStr = line.slice(6).trim()
          if (jsonStr) {
            try {

View on GitHub (pinned to 073e92d171)

Solutions

  1. Confirm the endpoint actually returns a chunked/streamed body (curl -N test).
  2. Disable proxy buffering for this route (nginx: proxy_buffering off; X-Accel-Buffering: no header).
  3. Add a capability check for response.body before fetch when targeting old browsers, or switch to XHR-based streaming.
  4. Include response headers in the error (Content-Length, Content-Type) to diagnose empty responses.

Example fix

// before
const reader = response.body?.getReader()
if (!reader) {
  throw new Error('No response body')
}

// after
const reader = response.body?.getReader()
if (!reader) {
  const fallback = await response.text().catch(() => '')
  if (fallback) { handleNonStreamedPayload(fallback); return }
  throw new Error(`No response body (status ${response.status})`)
}
Defensive patterns

Strategy: validation

Validate before calling

if (typeof ReadableStream === 'undefined' || !Response.prototype.body) {
  showUnsupportedBrowserNotice(); // before starting the streaming request
}

Try / catch

try { await runStream(); }
catch (e) {
  if (e.message === 'No response body') {
    showError('Streaming unavailable — check proxy or browser'); return;
  }
  throw e;
}

Prevention

When it happens

Trigger: The test endpoint returns 204/304 or an empty 200; a proxy (nginx buffering, Cloudflare, corporate proxy) strips the streamed body; the browser is old (pre-2017 Safari/Chrome) lacking fetch streaming; or the server responded and closed without a body via a misconfigured handler.

Common situations: Reverse proxy configured without chunked-transfer support or with proxy_buffering that collapses the stream; server handler returning Response with no body on a success path; WebView-based mobile browsers.

Related errors


AI-assisted analysis of Wei-Shaw/sub2api@073e92d171 (2026-08-15). Data as JSON: /api/errors/53b2133d0e2c4aa4. Report an issue: GitHub.