Skip to content

Fix SQS 15-minute delay limit for timers#294

Merged
rmcdaniel merged 1 commit intomasterfrom
fix/sqs-timers
Dec 4, 2025
Merged

Fix SQS 15-minute delay limit for timers#294
rmcdaniel merged 1 commit intomasterfrom
fix/sqs-timers

Conversation

@rmcdaniel
Copy link
Copy Markdown
Member

Problem

Amazon SQS has a maximum message delay of 15 minutes (900 seconds). When using WorkflowStub::timer() or WorkflowStub::awaitWithTimeout() with delays greater than 900 seconds on an SQS queue, the workflow would fail.

Solution

When the queue driver is SQS, cap the Signal dispatch delay at 900 seconds. The workflow will automatically wake up after 900 seconds, check if enough time has passed, and if not, schedule another delay. This chunking process repeats until the full timer duration has elapsed.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (fc9c8f6) to head (3439aaa).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##              master      #294   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       333       335    +2     
===========================================
  Files             47        47           
  Lines           1377      1384    +7     
===========================================
+ Hits            1377      1384    +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rmcdaniel rmcdaniel merged commit 201dcef into master Dec 4, 2025
3 checks passed
@rmcdaniel rmcdaniel deleted the fix/sqs-timers branch December 4, 2025 23:51
rmcdaniel pushed a commit that referenced this pull request Apr 16, 2026
Mirror the helpers under Workflow\V2\functions.php as static methods on
the Workflow abstract base class so v2 authors can write:

    use Workflow\V2\Workflow;

    final class MyWorkflow extends Workflow
    {
        public function handle(): mixed
        {
            $result = Workflow::activity(SendEmail::class, $input);
            Workflow::timer('5 seconds');
            Workflow::upsertMemo(['stage' => 'done']);

            return $result;
        }
    }

Each static is a thin delegate to the equivalent namespaced helper
(activity, child, async, all, parallel, await, awaitWithTimeout,
awaitSignal, timer, sideEffect, continueAsNew, getVersion, upsertMemo,
upsertSearchAttributes, seconds/minutes/hours/days/weeks/months/years,
plus executeActivity and executeChildWorkflow aliases). The namespaced
helpers remain in place as the functional-style alternative.

The existing instance convenience `$this->child()` — which returns the
most recently spawned ChildWorkflowHandle — conflicted with the new
static `Workflow::child(...)` spawn API. Renamed the instance method to
`$this->lastChild()` and updated the four V2 test fixtures that used
it. No v1 back-compat shim is needed because v2 is unpublished.

Also update the v2 scaffolding stub to show Workflow:: usage in a
commented example so new workflows ship with the facade-idiomatic form.

docs/api-stability.md now documents the authoring facade as part of the
v2 public API surface alongside the Contracts\* interfaces and the
server-facing Support\* stability list.

Deferred from #171 to a follow-up: `Workflow::now()` (needs new
deterministic workflow-time machinery), and the `startActivity` /
`startChild` fire-and-forget variants (not yet represented in the
runtime primitives).

Refs #294 (blocker), #171.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant