Repository navigation
temporal-ruby SDK: Add support for next_retry_delay in Activity errors to more intelligently back off activity retries - #7
Open
kstewartfigma wants to merge 3 commits into
Conversation
kstewartfigma
requested review from
a team,
adirar-figma and
yfang-figma
and removed request for
a team
October 30, 2026 23:08
kstewartfigma
marked this pull request as ready for review
October 30, 2026 23:10
yfang-figma
approved these changes
Nov 2, 2026
| if retry_delay | ||
| # Older failures may carry zero; preserve their metadata without applying outbound validation. | ||
| Temporal::RetryDelay.restore(exception, | ||
| retry_delay.seconds + retry_delay.nanos.quo(1_000_000_000).to_f) |
There was a problem hiding this comment.
AI suggested that this is different than (retry_delay.seconds + retry_delay.nanos.quo(1_000_000_000)).to_f which is used in the first party sdk, https://github.com/temporalio/sdk-ruby/blob/3aa06a665402e340100b64890143ba966a49a536/temporalio/lib/temporalio/internal/proto_utils.rb#L16-L24.
Let's keep them consistent?
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.
Written with AI
Description
Activities can opt into specifying a particular retry delay when an external service supplies
Retry-After. An exception class includesTemporal::RetryDelay, setsnext_retry_delayin seconds, and keeps its original class and exception payload across legacy and v2 serialization. The delay replaces the retry interval; Temporal still enforces maximum attempts and timeouts.Outbound delays must be at least 1 nanosecond because Temporal Server 1.32 treats a zero custom delay as a retry timeout. Historical inbound zero delays remain readable and are omitted if the error is raised again.
Changes
Backport
ApplicationFailureInfo.next_retry_delayonto the pinned API descriptor with an idempotent Ruby script run bymake proto.Serialize and reconstruct opted-in error metadata while leaving ordinary exceptions unchanged.
Add unit and opt-in live server coverage, API documentation, and a first-party parity map against the pinned official Ruby SDK revision.
Run CI on Ruby 3.4 to satisfy the existing protobuf dependency. Explicitly load OpenStruct in test setup, pass replay-fixture inputs as a positional hash, and accept qualified Ruby 3.4 method names in stack-trace assertions.
Test Plan
November 16 validation on Coder, Ruby 3.4.7, with isolated freshly resolved dependencies (protobuf 4.33.6, gRPC 1.85.0, Fabrication 3.0.0, RSpec 3.10):
bundle exec rspec: 653 examples, 0 failures, 1 pending. The pending test is the opt-in live retry-delay spec requiringTEMPORAL_TEST_PORT; it was not enabled in this run.examples/suite with CI's Temporal Server 1.22.0, Cassandra 3.11, and the general, encryption, and v2-error workers: 91 examples, 0 failures.abeeff1: combine seconds and nanoseconds before converting to Float, matching the first-party SDK.git diff --checkpasses.The failed previous CI run stopped during dependency resolution: Ruby 3.0.3 could not install the existing protobuf 4.33 dependency, which requires Ruby >=3.1. After upgrading the runtime, the test-fixture fixes also resolve the previously recorded replay/stack-trace failures and the missing OpenStruct load.
Earlier live contract and generation validation
On October 19, the original feature head
2ac619e4b6126918b45462e529862a558cbc1c91passed its live retry-delay integration test against Temporal Server 1.32.0 on Coder. It verified failure metadata seconds=2/nanos=300000000, a 2.3-second custom delay overriding a one-second policy maximum, exactly two activity attempts, and preservation of the error class, message, and delay. Bundledmake protoran twice with pinned submoduleae312b0724003957b96fb966e3fe25a02abaade4and exactly reproduced the committed generated files. These results supersede the earlier authentication/macOS tooling blockers.Limits: the live 1.32 contract test and protobuf regeneration were not rerun for the subsequent rounding and CI-only changes. The hosted Ruby 3.4 patch can differ from Coder's 3.4.7; the new GitHub run validates that environment. The 1.22 example suite does not establish support for the new retry-delay server feature.