Is this the expected behavior when running in worker mode? #1250
-
I have an interesting problem where a certain header, which is set only in a search area, once set, it will be part of all requests. In a state provider, I am doing something like: public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
{
if ($operation instanceof CollectionOperationInterface) {
...
$this->responseCustomHeaders->add([
'X-JobSearch-Id' => (int) Carbon::now()->timestamp,
]);
...
return new TraversablePaginator(
...
);
}
return [];
} Once set, the Is the state of this service shared between all requests? Should I reset these custom headers when I am done with them? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This looks intended. Your service must implement the Symfony Would you mind to share the code of this service? |
Beta Was this translation helpful? Give feedback.
Indeed the service is the problem. I don't why you need a service here instead of attaching the custom' headers directly to the current request.
The
ResetInterface
is not FrankenPHP-specific (it is also useful for Messenger, Swoole etc) but indeed we should add some docs for it in this context (here is the existing docs: https://symfony.com/doc/current/messenger.html#stateless-worker).While convenient, it's almost always possible to design stateless services instead (which is a best practice anyway).