[Cloudflare] instrumentWorkflowWithSentry does not capture a NonRetryableError thrown before the final attempt

未关闭 适合新手
#26,091 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript

调研方向

先阅读 instrumentWorkflowWithSentry 和 WrappedWorkflowStep.do,尤其是 instrumentedCallback,目前是否捕获取决于尝试次数。检查现有的 Cloudflare workflow instrumentation 测试,并补充对最后一次重试之前抛出 NonRetryableError 的测试。完成标准是该失败会产生一个 Sentry 事件,同时仍有测试覆盖重试次数耗尽时的行为。

由索引模型根据 Issue 内容生成。

描述

Bug Cloudflare Workers
Is there an existing issue for this?

Related: #17421, #21025

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/cloudflare

SDK Version

11.9.0 (the code is the same in 11.10.0 and on develop)

Framework Version

wrangler 4.98.0, compatibility_date 2025-06-04

Reproduction Example/SDK Setup
import { WorkflowEntrypoint } from 'cloudflare:workers'
import { NonRetryableError } from 'cloudflare:workflows'
import * as Sentry from '@sentry/cloudflare'

class MyWorkflow extends WorkflowEntrypoint<Env, Params> {
  async run(event, step) {
    await step.do('load', { retries: { limit: 2, delay: '1 second' } }, async () => {
      throw new NonRetryableError('permanent failure')
    })
  }
}

export const Instrumented = Sentry.instrumentWorkflowWithSentry(
  (env) => ({ dsn: env.SENTRY_DSN }),
  MyWorkflow,
)
Steps to Reproduce
  1. Wrap a Workflow with instrumentWorkflowWithSentry.
  2. Throw a NonRetryableError in a step.do with retries.limit > 0.
  3. Trigger an instance.
Expected Result

One Sentry event for the NonRetryableError that ends the instance.

Actual Result

No event. WrappedWorkflowStep.do only captures when attempt > retries.limit, and a NonRetryableError ends the instance on attempt 1. Regression since 10.56.0 (#21025): before, the step error was captured on every attempt, so it was reported.

Additional Context

#17421 asked for one error "once all step.do retries have been exhausted, or on a NonRetryableError". #21025 covered only the first case.

Suggested fix: in instrumentedCallback, also capture when error.name === 'NonRetryableError'. I'm happy to open a PR with integration tests.

主要语言
TypeScript
星标
8.8k
派生
1.9k
平均合并
1 天 20 小时
30 天内合并 PR
682

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-javascript 的其他 Issue

查看 getsentry/sentry-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。