Skip action if response already sent by init hook#234
Conversation
If an init hook (e.g. cache) calls $response->send(), the action should not run — the response has already been delivered to the client. Without this guard the action executes in full, wasting worker time on work whose output is immediately discarded. Shutdown hooks still run so metrics, billing, and other teardown logic are unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR adds a guard in Confidence Score: 5/5Safe to merge — the critical undefined-variable bug from the first commit is fully resolved, and the guard logic is correct. The only open concern (missing test for the No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "Fix: pass Response to execute() so isSen..." | Re-trigger Greptile |
| if (!$response->isSent()) { | ||
| $arguments = $this->getArguments($route, $pathValues, $request->getParams()); | ||
| \call_user_func_array($route->getAction(), $arguments); | ||
| } |
There was a problem hiding this comment.
No unit test for the new guard
The PR description lists three test-plan items (all unchecked). There is no new test case in tests/HttpTest.php or the e2e suite that verifies an init hook calling $response->send() actually skips the route action while still executing shutdown hooks. Without a test, a future refactor could silently regress this behavior.
The 0.34.x execute() method had dropped the Response parameter compared to 0.33.x, meaning $response->isSent() in the action guard would be an undefined variable. Restore the parameter and update all call sites in the test suite. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
$response->send()to deliver a cached response directly to the clientsend()isSent()check before dispatching the action; shutdown hooks still run so metrics, billing, and teardown logic are unaffectedTest plan
$response->send()no longer executes the action🤖 Generated with Claude Code