{"record":{"id":"4c9de7732acd20c8","repo":"mastra-ai/mastra","slug":"failed-to-stream-workflow-response-statustext","errorCode":null,"errorMessage":"Failed to stream workflow: ${response.statusText}","messagePattern":"Failed to stream workflow: (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"client-sdks/client-js/src/resources/run.ts","lineNumber":240,"sourceCode":"    searchParams.set('runId', this.runId);\n\n    const requestContext = parseClientRequestContext(params.requestContext);\n    const response: Response = await this.request(`/workflows/${this.workflowId}/stream?${searchParams.toString()}`, {\n      method: 'POST',\n      body: {\n        inputData: params.inputData,\n        initialState: params.initialState,\n        requestContext,\n        tracingOptions: params.tracingOptions,\n        resourceId: params.resourceId,\n        perStep: params.perStep,\n        closeOnSuspend: params.closeOnSuspend,\n      },\n      stream: true,\n    });\n\n    if (!response.ok) {\n      throw new Error(`Failed to stream workflow: ${response.statusText}`);\n    }\n\n    if (!response.body) {\n      throw new Error('Response body is null');\n    }\n\n    // Pipe the response body through the transform stream\n    return response.body.pipeThrough(this.createChunkTransformStream());\n  }\n\n  /**\n   * Observe (reconnect to) an existing workflow stream.\n   * Use this to resume receiving events after a disconnection.\n   *\n   * @param params.offset - Optional position to resume from (0-based). If omitted, replays all events.\n   * @returns Promise containing a ReadableStream of workflow events\n   *\n   * @example","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/client-sdks/client-js/src/resources/run.ts#L222-L258","documentation":"Thrown by Run.stream() when the workflow streaming POST returns a non-OK HTTP status. The library surfaces the HTTP statusText because the response is not a usable event stream. The server-side reason is not included, so check the status code/statusText for the cause.","triggerScenarios":"Calling run.stream() with params like closeOnSuspend where the server responds 4xx/5xx — e.g. unknown run ID, run already completed, or server error (client-sdks/client-js/src/resources/run.ts:240).","commonSituations":"Resuming a stale run ID after server restart; concurrent runs conflicting; server returning 500 due to workflow definition errors.","solutions":["Log the full HTTP response status; if needed use the non-streaming request path to get the error body.","Verify the run ID and workflow ID are valid and the run is in a streamable state.","Check Mastra server logs for the underlying 4xx/5xx cause.","Retry transient 5xx failures with backoff."],"exampleFix":"// before\nconst stream = await run.stream({ inputData });\n\n// after\ntry {\n  const stream = await run.stream({ inputData });\n} catch (e) {\n  console.error('Workflow stream failed:', e.message); // includes statusText\n}","handlingStrategy":"try-catch","validationCode":"const status = await run.status();\nif (['success', 'failed'].includes(status.status)) throw new Error(`Run ${runId} not streamable (${status.status})`);","typeGuard":"function isStreamable(status: { status: string }): boolean {\n  return ['pending', 'running', 'waiting', 'suspended'].includes(status.status);\n}","tryCatchPattern":"try {\n  const stream = await run.stream({ inputData });\n} catch (e) {\n  if (/Failed to stream workflow/.test(e.message)) {\n    console.error('Stream rejected:', e.message);\n    // check server logs / fall back to run.start()\n  } else throw e;\n}","preventionTips":["Check run state before streaming","Keep run IDs fresh across server restarts","Log statusText and correlate with server logs","Retry 5xx with backoff"],"tags":["network","streaming","workflow"],"backgroundTag":"http-error-response","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}