diff --git a/src/Listeners/FlushTemporaryContainerInstances.php b/src/Listeners/FlushTemporaryContainerInstances.php index 12fed61a3..003e0c22e 100644 --- a/src/Listeners/FlushTemporaryContainerInstances.php +++ b/src/Listeners/FlushTemporaryContainerInstances.php @@ -12,9 +12,12 @@ class FlushTemporaryContainerInstances */ public function handle($event): void { + if (method_exists($event->app, 'resetScope')) { + $event->app->resetScope(); + } + foreach ($event->sandbox->make('config')->get('octane.flush', []) as $binding) { $event->app->forgetInstance($binding); - $event->sandbox->forgetInstance($binding); } } } diff --git a/src/Worker.php b/src/Worker.php index 8dc27056e..61fcf0ec3 100644 --- a/src/Worker.php +++ b/src/Worker.php @@ -151,6 +151,8 @@ public function handleTask($data) return TaskExceptionResult::from($e); } finally { + $sandbox->flush(); + // After the request handling process has completed we will unset some variables // plus reset the current application state back to its original state before // it was cloned. Then we will be ready for the next worker iteration loop. @@ -177,6 +179,8 @@ public function handleTick(): void } catch (Throwable $e) { $this->dispatchEvent($sandbox, new WorkerErrorOccurred($e, $sandbox)); } finally { + $sandbox->flush(); + unset($sandbox); CurrentApplication::set($this->app);