Fix null worker crash in Swoole during code reload#1110
Draft
JoshSalway wants to merge 1 commit intolaravel:2.xfrom
Draft
Fix null worker crash in Swoole during code reload#1110JoshSalway wants to merge 1 commit intolaravel:2.xfrom
JoshSalway wants to merge 1 commit intolaravel:2.xfrom
Conversation
When using the file watcher with Swoole, the worker process is briefly destroyed and recreated during hot-reload. If a request arrives during this window, accessing the null worker/client properties causes a fatal error. This adds a null guard that returns a 503 response instead. Fixes laravel#1053 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a crash in Swoole's request handler where
$workerState->workeror$workerState->clientis null during file watcher reloads, causing a fatal "Call to a member function handle() on null" error.Fixes #1053
Problem
When Swoole's file watcher triggers a reload, there is a brief window where the worker state is being re-initialized. Requests arriving during this window hit a null
$workerState->worker, causing:This crashes the entire worker process rather than gracefully handling the transient state.
Solution
Add a null guard for
$workerState->workerand$workerState->clientin the Swoole request handler. If either is null (worker still initializing after reload), return a 503 Service Unavailable response instead of crashing.Before/After
Before: Requests during reload window cause a fatal error, killing the worker process.
After: Requests during reload window receive a 503 response. Normal requests work immediately after the reload completes.
Test Plan