Skip to content

Conversation

@pindab0ter
Copy link
Contributor

Problem

In long-lived processes such as Laravel Octane or Pest Browser's Amp-based HTTP server, a precognitive request permanently pollutes the container. Subsequent non-precognitive requests resolve PrecognitionCallableDispatcher instead of the original CallableDispatcher, causing the controller to be skipped and a 204 response to be returned.

Cause

HandlePrecognitiveRequests::prepareForPrecognition() overrides the CallableDispatcherContract and ControllerDispatcherContract bindings with precognition variants using bind(), but never restores the original singleton() bindings.

In PHP-FPM this is harmless because the process dies after each request, but in long-lived processes the polluted bindings persist across requests.

Solution

Capture the original bindings before overriding them in prepareForPrecognition(), then restore them in the tap callback after the precognitive response is prepared.

Fixes pestphp/pest#1579

@taylorotwell taylorotwell merged commit 717a176 into laravel:12.x Feb 9, 2026
69 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]: Browser testing does not work with Laravel Precognition

2 participants