Problem/Motivation

/Drupal\o365_sso\Controller\LoginCallbackController->callback
RuntimeException: Failed to start the session because headers have already been sent by "/app/vendor/symfony/http-foundation/Response.php" at line 377. in /app/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php on line 150 #0 /app/html/core/lib/Drupal/Core/Session/SessionManager.php(164):

Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
#1 /app/html/core/lib/Drupal/Core/Session/SessionManager.php(118): Drupal\Core\Session\SessionManager->startNow()
#2 /app/vendor/symfony/http-foundation/Session/Session.php(57): Drupal\Core\Session\SessionManager->start()
#3 /app/html/core/modules/big_pipe/src/Render/BigPipe.php(240): Symfony\Component\HttpFoundation\Session\Session->start()
#4 /app/html/core/modules/big_pipe/src/Render/BigPipe.php(295): Drupal\big_pipe\Render\BigPipe->performPreSendTasks()
#5 /app/html/core/modules/big_pipe/src/Render/BigPipeResponse.php(112): Drupal\big_pipe\Render\BigPipe->sendContent(Object(Drupal\big_pipe\Render\BigPipeResponse))
#6 /app/vendor/symfony/http-foundation/Response.php(374): Drupal\big_pipe\Render\BigPipeResponse->sendContent()
#7 /app/html/index.php(20): Symfony\Component\HttpFoundation\Response->send()

Steps to reproduce

Do login via o365 SSO.

Proposed resolution

Return Redirect Response objects in Controllers instead of execution send() method.

Comments

mdeny created an issue. See original summary.

denysyukm@gmail.com’s picture

Status: Active » Needs review
al_trottier’s picture

Creating a patch based on mdeny's proposed fix.

pvasener’s picture

This MR fixed the problem for me.

nicholass’s picture

This also fixes the 3.0x branch but the patch from the merge request could not be applied. But when I apply it manually the error is fixed.

nicholass’s picture

Status: Needs review » Reviewed & tested by the community
nicholass’s picture

Status: Reviewed & tested by the community » Needs review
nicholass’s picture

Drupal v9.3.2
0365 v3.0.4

Although the original error about session headers already being sent is gone, another error for me still exists.

LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\Core\Routing\TrustedRedirectResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->

  • fabianderijk committed 8d6da5e on 3.0.x
    Issue #3196456 by al_trottier: RuntimeException in...

  • fabianderijk committed f929746 on 2.0.x
    Issue #3196456 by al_trottier: RuntimeException in...
fabianderijk’s picture

Status: Needs review » Fixed

This has now been fixed (in a bit different way) for both the 2.0.x and 3.0.x branches. Releases 2.0.5 and 3.0.5 have been created for this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.