feat(functions): add opt-in durable HTTP failure retries - #377
Open
wangbill (YunchuWang) wants to merge 1 commit into
Open
wangbill (YunchuWang) wants to merge 1 commit into
wangbill (YunchuWang) wants to merge 1 commit into
Conversation
Add HttpRetryOptions and serialize its policy and status-code snapshot for the built-in HTTP activity. Reuse durable RetryPolicy execution, preserve calls without options, and match .NET in-process initial-request-only retry semantics. Closes #367 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e0af01a5-0dfa-4e71-a660-c4186e65d7e0
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Retriable responses are fully buffered before status evaluation, which can delay or prevent durable retries for large or non-terminating bodies.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds opt-in durable HTTP retries to classic callHttp, reusing core activity retries and preserving separate 202 polling behavior.
Changes:
- Adds and exports
HttpRetryOptions. - Applies durable retries to configured HTTP statuses and transport failures.
- Documents behavior and adds replay, timeout, polling, and exhaustion tests.
| File | Description |
|---|---|
src/http/models.ts |
Defines HTTP retry options and payload fields. |
src/http/builtin.ts |
Applies retry policies to initial HTTP requests. |
src/orchestration-context.ts |
Snapshots retry configuration into durable requests. |
src/index.ts |
Exports HttpRetryOptions. |
test/unit/http-retry.spec.ts |
Tests HTTP retry execution and replay. |
test/unit/orchestration-context.spec.ts |
Tests policy validation and serialization. |
README.md |
Documents usage and semantics. |
CHANGELOG.md |
Records the feature. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
304
to
+314
| const content = await response.text(); | ||
|
|
||
| if (request.retryOptions !== undefined) { | ||
| const codes = request.retryOptions.statusCodesToRetry; | ||
| const shouldRetry = codes?.length | ||
| ? codes.includes(response.status) | ||
| : response.status < 200 || response.status >= 300; | ||
| if (shouldRetry) { | ||
| throw new Error(`HTTP request failed with status code ${response.status}.`); | ||
| } | ||
| } |
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.

Summary
What changed?
HttpRetryOptionsandcallHttp({ retryOptions }), snapshotting the policy and status list into the durable request.Why is this change needed?
Previously
callHttpreturned error status responses without durable failure retries. With explicit options it now retries selected responses, returns excluded statuses, and throwsTaskFailedErroron exhaustion rather than returning the last failed response.The reference is the .NET in-process Durable Functions extension, not the generic .NET SDK:
HttpRetryOptions: backoff 1, six-day interval cap, unlimited retry timeout by default.TaskHttpActivityShim: omitted/empty status lists use non-2xx semantics (including 4xx/5xx and unfollowed 3xx); explicit lists are exact, including 202.CreateLocationPollRequestdoes not propagate retry options. This PR matches that boundary: initial requests retry; subsequent 202 Location polls do not. Initial503 -> 202 -> poll 503therefore returns the poll's 503 without retrying it.Omitting options preserves current behavior. Existing polling, redirects, credential stripping, and URL validation are unchanged. README documents JavaScript millisecond/
-1conventions, core retry-timeout boundaries, idempotency considerations, and versioning/draining in-flight instances before enabling retries.Issues / work items
Project checklist
packages/azure-functions-durable/CHANGELOG.mdAI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
AI verification (required if AI was used):
Testing
Automated tests
npm run build -w durable-functions(includes core build), scoped ESLint, Prettier with baseline CRLF, andgit diff --check.Manual validation (only if runtime/behavior changed)
127.0.0.1:10000. No environment was provisioned. Full-repository suites, sidecar/Azure tests, and hosted CI are not claimed as passed.Notes for reviewers