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

Aperta Adatta ai principianti
#26,091 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Inizia leggendo instrumentWorkflowWithSentry e WrappedWorkflowStep.do, in particolare instrumentedCallback, dove la cattura dipende attualmente dal numero di tentativi. Controlla i test esistenti per la strumentazione dei workflow Cloudflare e aggiungi una copertura per un NonRetryableError generato prima dell’ultimo tentativo di ripetizione. Il lavoro è completato quando tale errore produce un evento Sentry e il comportamento all’esaurimento dei tentativi resta coperto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
8.8k
Fork
1.9k
Merge medio
1g 20h
PR unite (30g)
682

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getsentry/sentry-javascript

Tutte le issue di getsentry/sentry-javascript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.