Long-running workers
Application servers such as RoadRunner, Swoole and FrankenPHP in worker mode handle many requests in the same PHP process. Services live across requests, so any data they store leaks from one request to the next.
The adapter is designed for this:
InertiaandInertiaMiddlewarehold only configuration.with*()methods return new instances instead of changing the service.- Request-specific data, such as shared props, validation errors and history flags, is stored in request attributes.
ManifestVersionandVitecache the manifest and re-read it only when the file changes.PhpRootViewRendererrenders the template in an isolated scope.
What to watch in your code
- Share per-user data with
Inertia::share($request, ...)in a middleware, not withwithSharedProps()on a shared service. - Closures in
sharedPropsparams run on every render, so they may read request-independent data but must not capture objects that hold request state. - A custom
FlashStoreInterfacemust store data per session, not in the object. - A custom
RootViewRendererInterfacethat uses a stateful view, such asWebView, should callwithClearedState()before rendering.