Skip to content

Commit

Permalink
🐛 fix serialization of guzzle Middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti committed Dec 8, 2023
1 parent cd64d30 commit e8f7387
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Classes/Utility/GuzzleUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ public static function getHandler(): ?Closure

// 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 ($sentryService, $timingUtility, $handler): PromiseInterface {
return static fn(callable $handler): Closure => static function (RequestInterface $request, array $options) use ($handler): PromiseInterface {

Check warning on line 27 in Classes/Utility/GuzzleUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/GuzzleUtility.php#L27

Added line #L27 was not covered by tests
try {
GeneralUtility::getContainer();
} catch (\LogicException) {

Check warning on line 30 in Classes/Utility/GuzzleUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/GuzzleUtility.php#L29-L30

Added lines #L29 - L30 were not covered by tests
// container not found:
// than we are most likely in a subprocess (spatie/async)
// and we don't want to initialize the container here!
return $handler($request, $options);

Check warning on line 34 in Classes/Utility/GuzzleUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/GuzzleUtility.php#L34

Added line #L34 was not covered by tests
}

$info = $request->getMethod() . ' ' . $request->getUri()->__toString();
$stop = $timingUtility->stopWatchInternal('http.client', $info);
$request = $sentryService->addSentryTraceHeaders($request, $stop);
$stop = TimingUtility::getInstance()->stopWatchInternal('http.client', $info);
$request = GeneralUtility::makeInstance(SentryService::class)->addSentryTraceHeaders($request, $stop);

Check warning on line 39 in Classes/Utility/GuzzleUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/GuzzleUtility.php#L38-L39

Added lines #L38 - L39 were not covered by tests

$handlerPromiseCallback = static function ($responseOrException) use ($request, $stop) {
$response = null;
Expand Down

0 comments on commit e8f7387

Please sign in to comment.