惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
博客园_首页
S
SegmentFault 最新的问题
罗磊的独立博客
博客园 - 【当耐特】
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
D
Docker
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
V
V2EX
大猫的无限游戏
大猫的无限游戏
V
Visual Studio Blog
腾讯CDC
宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
Vercel News
Vercel News
H
Help Net Security
博客园 - Franky
D
DataBreaches.Net
aimingoo的专栏
aimingoo的专栏

Workflow SDK Documentation

Patterns for Defining Tools Human-in-the-Loop Building Durable AI Agents Queueing User Messages Resumable Streams Sleep, Suspense, and Scheduling Streaming Updates from Tools API Reference Workflow Globals Changelog Resilient run start Cookbook Building a World Deploying Astro Express Fastify Hono Getting Started NestJS Next.js Nitro Nuxt Python SvelteKit Vite corrupted-event-log fetch-in-workflow hook-conflict Errors
WorkflowRunFailedError
2026-05-31 · via Workflow SDK Documentation

Thrown when awaiting the return value of a failed workflow run.

WorkflowRunFailedError is thrown when awaiting run.returnValue on a workflow run whose status is 'failed'. This indicates that the workflow encountered a fatal error during execution and cannot produce a return value.

The cause property holds the original thrown value, hydrated through the workflow serialization pipeline so its type identity (e.g. FatalError, RetryableError, custom Error subclasses), cause chain, and custom properties are preserved. Because any JavaScript value can be thrown, cause is typed as unknown — narrow it with instanceof Error (or a more specific check) before accessing fields like message. The high-level error classification is exposed as the top-level errorCode property.

import { WorkflowRunFailedError } from "workflow/errors"
declare const run: { status: Promise<string>; returnValue: Promise<any> }; // @setup

try {
  const result = await run.returnValue;
} catch (error) {
  if (WorkflowRunFailedError.is(error)) { 
    if (error.cause instanceof Error) {
      console.error(`Run ${error.runId} failed:`, error.cause.message);
    }
    if (error.errorCode) {
      console.error("Error code:", error.errorCode);
    }
  }
}

Properties

NameTypeDescription
runIdstringThe ID of the failed run.
causeunknownThe original thrown value from the failed workflow run, hydrated through the workflow serialization pipeline. Preserves the original type identity (Error subclasses, FatalError, custom classes with WORKFLOW_SERIALIZE, etc.) and custom properties. Typed as unknown because any value can be thrown — narrow with instanceof Error before accessing fields.
errorCodestringThe high-level error category (e.g. USER_ERROR, RUNTIME_ERROR).
messagestringThe error message.

Static Methods

WorkflowRunFailedError.is(value)

Type-safe check for WorkflowRunFailedError instances. Preferred over instanceof because it works across module boundaries and VM contexts.

import { WorkflowRunFailedError } from "workflow/errors"
declare const error: unknown; // @setup

if (WorkflowRunFailedError.is(error)) {
  // error is typed as WorkflowRunFailedError
}