Repository navigation
fix: clear server exception on successful request and consumption - #324
helmipradita wants to merge 2 commits into
Conversation
7f49b94 to
5d8ec71
Compare
|
CI on this fork PR is |
|
Please clear the previous exception when a new navigation starts. A successful subrequest can currently erase the exception from the page that just failed. Add a regression test with a 500 page that loads a stylesheet, and chain an assertion onto |
LastThrowable was cleared whenever any request succeeded, so a stylesheet/script/XHR subrequest could erase the exception from the 500 page that just failed. Clear only on document/iframe navigation (or HTML accept fallback) at handleRequest start. Chain an assertion onto visit('/failing-route') so the existing regression test actually issues the request, and add a 500-page-loads-stylesheet case. Addresses MrPunyapal review on pestphp#324.
Signed-off-by: Helmi Pradita <helmipraditaa@gmail.com>
|
Thanks @MrPunyapal — both points addressed in
Checks run locally: |
Summary
When testing multi-step flows where an earlier request triggers an exception (e.g. asserting a 500 error or handling it via
expect(...)->toThrow(...)),LaravelHttpServer::$lastThrowablepreviously remained populated. When subsequent requests succeeded without exceptions,$lastThrowablewas not reset, causingthrowLastThrowableIfNeeded()to erroneously re-throw the stale exception on later assertions. Furthermore, throwing inthrowLastThrowableIfNeeded()did not clear the property, causing repeated throws.Changes
LaravelHttpServer::throwLastThrowableIfNeeded(), clear$this->lastThrowable = nullupon throwing so consumed exceptions are not re-thrown by subsequent checks.$this->lastThrowable = nullwhen$response->exceptionis null.LaravelHttpServerTest.phpverifying that a server exception on an earlier request does not leak into subsequent successful requests within the same test.Fixes pestphp/pest#2009 (Case 2).