Skip to content

fix(go): make retry backoff context-aware and honor client-scoped WithoutRetries - #17498

Merged
adidavid014 merged 1 commit into
mainfrom
devin/1787318854-go-retrier-fixes
Aug 25, 2026
Merged

fix(go): make retry backoff context-aware and honor client-scoped WithoutRetries#17498
adidavid014 merged 1 commit into
mainfrom
devin/1787318854-go-retrier-fixes

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Description

Two independent bugs in the generated Go internal/retrier.go, reported by name.com against fern-go-sdk 1.57.1 (namedotcom/core-api-go#4, #3). Both live in the go-v2 as-is template.

1. Backoff ignored the request context. r.run used time.Sleep(delay). The context is only checked before each attempt, so a cancelled/expired context was noticed only after the full sleep — with Retry-After honored up to maxRetryDelay (60s), a single 429 could hold a call a minute past the caller's deadline, and Ctrl-C wired to cancel() sat in the sleep.

- time.Sleep(delay)
+ if err := sleepWithContext(request.Context(), delay); err != nil {  // select on ctx.Done() vs timer.C
+     return nil, err
+ }

2. Client-scoped option.WithoutRetries() was silently dropped. NewRetrier read attempts out of retryOptions but never stored disabled, and Run only consulted the per-call options — so WithoutRetries() worked per call but was a no-op on the constructor, which is exactly where you'd opt out for an API of non-idempotent writes (shouldRetry is status-only, so POSTs retry on 5xx). Retrier now persists disabled; a request-scoped WithMaxAttempts still takes precedence over it.

Changes Made

  • generators/go-v2/base/src/asIs/internal/retrier.go_: context-aware sleepWithContext helper; Retrier.disabled field with request-scoped override precedence.
  • generators/go-v2/base/src/asIs/internal/retrier_test.go_: TestRetryWaitIsInterruptedByContext, TestDisableRetries (client-scoped, request-scoped, and MaxAttempts override cases).
  • Go SDK changelog entry (two fix summaries).
  • Regenerated seed/go-sdk/**/internal/retrier{,_test}.go snapshots.

Testing

  • Unit tests added/updated
  • Manual testing completed

Against seed/go-sdk/exhaustive/no-custom-config, go test ./internal/... passes with the fix. Reverting just internal/retrier.go to its pre-fix version (keeping the new tests) fails as expected:

--- FAIL: TestRetryWaitIsInterruptedByContext (5.03s)
    Expected the backoff to be interrupted by the context, took 5.025023787s
--- FAIL: TestDisableRetries/client-scoped_DisableRetries (3.16s)
    expected: 1  actual: 2
    --- PASS: TestDisableRetries/request-scoped_DisableRetries
    --- PASS: TestDisableRetries/request-scoped_MaxAttempts_overrides_client-scoped_DisableRetries

Link to Devin session: https://app.devin.ai/sessions/3783789dffe246c9871ebfbf25897445


Open in Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

SDK Generation Benchmark Results

Comparing PR branch against median of 5 nightly run(s) on main (latest: 2026-08-24T04:15:25Z).

Full benchmark table (click to expand)
Generator Spec main (generator) main (E2E) PR (generator) Delta
go-sdk square 137s (n=5) 298s (n=5) 141s +4s (+2.9%)

main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via fern generate). main (E2E): full customer-observable time including build/test scripts (nightly baseline, informational). Delta is computed against generator-only baseline.
⚠️ = generation exited with a non-zero exit code (timing may not reflect a successful run).
Baseline from nightly runs on main (latest: 2026-08-24T04:15:25Z). Trigger benchmark-baseline to refresh.
Last updated: 2026-08-24 19:30 UTC

…houtRetries

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1787318854-go-retrier-fixes branch from 96550c7 to baff212 Compare August 24, 2026 19:19
@adidavid014
adidavid014 merged commit 602b47e into main Aug 25, 2026
77 checks passed
@adidavid014
adidavid014 deleted the devin/1787318854-go-retrier-fixes branch August 25, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants