fix(admin): rethrow task-dispatched handler failures after logging - #129
Open
detail-app[bot] wants to merge 1 commit into
Open
detail-app[bot] wants to merge 1 commit into
detail-app[bot] wants to merge 1 commit into
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detail bug report: View on Detail
Bug
onTaskDispatchedEffectlogged handler failures in its.catchand returned normally, so the underlyingfirebase-functionstask-queue handler (onDispatchHandler) answered HTTP 204. Cloud Tasks treats any2xx(incl.204) as success and deletes the task, soretryConfigwas inert on the handler-failure path — a transient failure (downstream 5xx, DB timeout, rate-limit) was permanently dequeued after one attempt. Introduced in423946a; mirrors the swallow already fixed foronScheduleEffectinee0385e.Fix
Rethrow after logging in the wrapper's
.catch(packages/admin/src/lib/functions/on-task-dispatched.ts), matching theonScheduleEffectprecedent (ee0385e). The SDK now forwards a non-2xxstatus to Cloud Tasks: a plainError→internal→500, anHttpsError→ its mapped status. Cloud Tasks then retries perretryConfig(5xx is retry-class) or applies its 4xx policy.Effect.succeedremains the ack/no-retry signal.Testing
on-task-dispatched.spec.ts, 5 tests) drive the full SDKonDispatchHandlerHTTP boundary viafunc(req, res): success →204, plainErrorfailure →500,HttpsError('unavailable')→503,onSetupErrorack of a malformed payload →204, and a decode defect with noonSetupError→500. Full admin suite passes (75 tests, 9 files).expected 204 to be 500/503(the swallow), while the two success/recovery tests still pass; restore the fix, all pass — confirming the spec actually guards the rethrow.it.eachover the fullHttpsErrorcode→status map and 4logger.errorspy tests — all passed — but trimmed them from the final spec to keep it focused on the retry-contract footgun; a singleunavailable → 503case remains as the forwarding representative.nx run-many -t build), ESLint, and Prettier all clean;nx affected -t lint test build(CI parity) green.demo-project to skip production API auth, added a syntheticdist/package.jsonfor runtime detection). With the fix, a fallible handler (Effect.fail,retryConfig.maxAttempts: 3) answered HTTP500and the Cloud Tasks emulator retried the task tomaxAttemptsexhaustion then marked it FAILED. With the fix reverted, the same handler answered HTTP204and the task was executed once then deleted with no retry (failedTasks: 0). This closes the204 ⇒ delete/5xx ⇒ retrychain that the unit tests stop one hop short of.Closes #110
Automatic Fixes PRs can be configured here.