Skip to content

Fix event delivery stopping after a failed function subscriber - #13661

Merged
HarshMN2345 merged 6 commits into
mainfrom
codex/fix-7205-event-subscriber-failures
Sep 21, 2026
Merged

HarshMN2345 merged 6 commits into
mainfrom
codex/fix-7205-event-subscriber-failures

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

When several functions subscribe to the same event, an executor failure in an earlier function records its failed execution and then throws out of the subscriber loop. Later matching functions never run.

Catch execution failures per subscriber, continue through the remaining subscribers and pages, then rethrow the first failure. The event job still reaches the failed queue; this preserves existing retry behavior, including the possibility of repeating successful subscribers when the whole event is retried. This is the same shape the Notifications worker already uses for its per-recipient fan-out.

The E2E regression subscribes two failing functions to one unique user event. Whichever one the worker reaches first, the other records an execution only if the fan-out survived that failure, so the test fails on the pre-fix worker regardless of subscriber order. A one second function timeout makes the executor throw while preparing the runtime, which is the failure that used to abort the loop; the runtime's own soft timeout would mark the execution failed without throwing. testEventTrigger continues to cover a healthy subscriber receiving the event payload.

Validation: PHP syntax, Pint, targeted PHPStan level 4 and Rector dry-run pass. CI results below.

Fixes #7205.

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → codex/fix-7205-event-subscriber-failures (after).

Metric Before After Change
🚀 Requests/sec 192.73 181.86 🔴 -5.6%
⏱️ Latency P50 88.5 ms 96.4 ms 🔴 +8.9%
⏱️ Latency P95 211.26 ms 219.45 ms ⚪ +3.9%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 96.4 219.45 11,457 181.86 +8.19
Account 184.39 337.53 603 10.03 -9.06
TablesDB 92.9 175.39 6,231 100.4 +8.61
Storage 88.79 188.12 3,015 50.63 +23.6
Functions 134.07 260.02 1,608 27.69 -15.09

Top API waits (after)

API request Max wait (ms)
account.name.update 544.66
tablesdb.rows.get 486.55
account.prefs.update 479.88
tablesdb.rows.increment 406.64
functions.variables.create 400.48

@HarshMN2345
HarshMN2345 marked this pull request as ready for review September 14, 2026 12:31
@greptile-apps

greptile-apps Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge because subscriber failures no longer interrupt fan-out, and the retry-triggering failure is still propagated afterward.

Fix All in Claude CodeFindings

  1. P2 Test Depends on Internal Ordering ▶
Fix with agent prompt
### Issue 1
tests/e2e/Services/Functions/FunctionsCustomServerTest.php:2542-2543
This regression test assumes the timeout subscriber runs first because it was created first. That only holds because the current worker sorts functions by `$sequence`. If subscribers are validly reordered, the successful function could run before the timeout, allowing the old broken behavior to pass this test. This violates the repository directive to test observable behavior rather than mirror source ordering. Use observable synchronization that guarantees the failure happens before checking that the later subscriber ran; this repository requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR preserves function-event fan-out when an individual subscriber throws, while retaining the event job's existing retry behavior.

  • Captures the first subscriber failure and continues processing all matching subscribers and pages before rethrowing it.
  • Adds an order-independent E2E regression using two failing subscribers and verifies that both record failed event executions.

Reviews (4) · Last reviewed commit: "Merge branch 'main' into codex/fix-7205-..."

Comment on lines +2542 to +2543
// Subscribers run in creation order, so the timeout must run first.
$functions[] = $this->setupDeployedFunction('Failing event subscriber', 'timeout', [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Test Depends on Internal Ordering

This regression test assumes the timeout subscriber runs first because it was created first. That only holds because the current worker sorts functions by $sequence. If subscribers are validly reordered, the successful function could run before the timeout, allowing the old broken behavior to pass this test. This violates the repository directive to test observable behavior rather than mirror source ordering. Use observable synchronization that guarantees the failure happens before checking that the later subscriber ran; this repository requirement must be satisfied before merging.

Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Services/Functions/FunctionsCustomServerTest.php
Line: 2542-2543

Comment:
**Test Depends on Internal Ordering**

This regression test assumes the timeout subscriber runs first because it was created first. That only holds because the current worker sorts functions by `$sequence`. If subscribers are validly reordered, the successful function could run before the timeout, allowing the old broken behavior to pass this test. This violates the repository directive to test observable behavior rather than mirror source ordering. Use observable synchronization that guarantees the failure happens before checking that the later subscriber ran; this repository requirement must be satisfied before merging.

**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

HarshMN2345 and others added 4 commits September 21, 2026 15:59
…r regression

The regression paired a failing subscriber with a successful one and relied on
the worker paging subscribers by $sequence to put the failure first. Reordering
the fan-out would have let the successful function run first, and the pre-fix
worker would have satisfied every assertion.

Subscribe two failing functions to the event instead. Whichever one the worker
reaches first, the other records an execution only if the fan-out survived that
failure, so the test fails on the old code regardless of order. The success path
stays covered by testEventTrigger.

Also raise the poll budget to 60s, since both subscribers now wait out the
executor's runtime preparation before their executions land.
Matches the same pattern in the Notifications worker, and frees $error, which
already means an execution's error string elsewhere in this file.
@HarshMN2345
HarshMN2345 merged commit edd9e66 into main Sep 21, 2026
8 checks passed
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.

🐛 Bug Report: Functions are not executing on event trigger.

2 participants