-
Notifications
You must be signed in to change notification settings - Fork 339
Could the CurrentApplication set method be concurrently unsafe? #241
Copy link
Copy link
Closed
Description
When a request comes in, we use CurrentApplication::set to set the current container. But is this concurrency safe?
public function handle(Request $request, RequestContext $context): void
{
CurrentApplication::set($sandbox = clone $this->app);
try {
// process...
} catch (Throwable $e) {
} finally {
CurrentApplication::set($this->app);
}
}For example:
worker1
request1 request2
| |
| |
V |
CurrentApplication::set($sandbox1 = clone $this->app); |
| |
| |
| V
| CurrentApplication::set($sandbox2 = clone $this->app);
|
V
app()->make(x) // ? use sandbox1 container or sandbox2 container.
| |
| |
V V
end end
When I use Container::getInstance in request 1, I'm probably getting the sandbox2 in request 2 set.
So, Is this allowed?
- Octane Version: ^0.3.2
- Laravel Version: ^8.12
- PHP Version: 8.0.3
- Server: Swoole
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.