Repository navigation
Fix event delivery stopping after a failed function subscriber - #13661
Conversation
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
| // Subscribers run in creation order, so the timeout must run first. | ||
| $functions[] = $this->setupDeployedFunction('Failing event subscriber', 'timeout', [ |
There was a problem hiding this 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)
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!
…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.
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.
testEventTriggercontinues 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.