Unhandled Promise Rejection in Cloudflare Workers: Does it surface as a 5xx response?
0 reputation · 11 Mar 2020, 08:13 UTC
Goal
Determine whether an unhandled rejection during a background fetch in a Cloudflare Worker results in a 5xx response that can be captured by alert rules, versus being silently swallowed and logged only.
Constraints
Workers runtime currently does not retry failed fetches, and alert rules can be tuned to aggregated error counts per minute. The behavior of unhandled rejections is not documented as final, and may change with future runtime releases.
Uncertainty
When a Promise returned by fetch is rejected without a catch clause, the runtime may either propagate the rejection to the caller, causing a 5xx response, or suppress it, leaving only a log entry. This distinction affects how alert thresholds should be set to avoid noise.
Questions
- In a Cloudflare Worker, does an unhandled Promise rejection during a background fetch surface as a 5xx HTTP status in the final response?
- Can alert rules be configured to trigger on such 5xx responses, and if so, what regex or metric pattern is required?
- Will future releases of the Workers runtime alter this behavior, and how can we test for consistency across updates?