Skip to content

Commit

Permalink
🐛 fix compatibility with spatie/async and staticfilecache
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti committed Sep 12, 2023
1 parent 529a15d commit 1256c6a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Classes/EventListener/BootCompletedEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __invoke(BootCompletedEvent $event): void
{
// we initialize TimingUtility here
// in the install tool, (eg. DB compare)
// at this point, the TimingUtility is found in the container, but at the shutdown state the TimingUtility is not found in the conatiner.
// at this point, the TimingUtility is found in the container, but at the shutdown state the TimingUtility is not found in the container.
// so if we initialize it right here and save it inside a static variable, then everything works as expected. (not the sentry part :/ )
TimingUtility::getInstance();
SqlLoggerCore11::registerSqlLogger();
Expand Down
10 changes: 7 additions & 3 deletions Classes/Utility/GuzzleUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ public static function getHandler(): ?Closure
// fix bug in Configuration Backend module
return null;
}
// initialize early: so the spatie/async with staticfilecache doesn't kill the process
// there is the problem that it has a subprocess where the Container is not initialized fully
$timingUtility = TimingUtility::getInstance();
$sentryService = GeneralUtility::makeInstance(SentryService::class);

return static fn(callable $handler): Closure => static function (RequestInterface $request, array $options) use ($handler): PromiseInterface {
return static fn(callable $handler): Closure => static function (RequestInterface $request, array $options) use ($sentryService, $timingUtility, $handler): PromiseInterface {
$info = $request->getMethod() . ' ' . $request->getUri()->__toString();
$stop = TimingUtility::stopWatch('http.client', $info);
$request = GeneralUtility::makeInstance(SentryService::class)->addSentryTraceHeaders($request, $stop);
$stop = $timingUtility->stopWatchInternal('http.client', $info);
$request = $sentryService->addSentryTraceHeaders($request, $stop);

$handlerPromiseCallback = static function ($responseOrException) use ($request, $stop) {
$response = null;
Expand Down
1 change: 1 addition & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
- '../Classes/{Dto,SqlLogging}/*'
- '../Classes/*/WrapMiddleware.php'
- '../Classes/*/XClassMiddlewareDispatcher.php'

Kanti\ServerTiming\Service\RegisterShutdownFunction\RegisterShutdownFunctionInterface:
class: Kanti\ServerTiming\Service\RegisterShutdownFunction\RegisterShutdownFunction

Expand Down

0 comments on commit 1256c6a

Please sign in to comment.