Fix Failed to start the session because headers have already been sent by http-foundation response

Created on 5 June 2024, 21 days ago
Updated 6 June 2024, 20 days ago

Problem/Motivation

Noticed a warning and php logged error on the first hit only

Steps to reproduce

Given a user visits a page for the first time
When the image takes 1 second longer to load
Then one page not found warning for the image is in the browser error log
And two items are logged in the back-end system logs

Message	RuntimeException: Failed to start the session because headers have already been sent by "/app/vendor/symfony/http-foundation/Response.php" at line 408. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 132 of /app/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php)
#0 /app/docroot/core/lib/Drupal/Core/Session/SessionManager.php(144): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
#1 /app/docroot/core/lib/Drupal/Core/Session/SessionManager.php(109): Drupal\Core\Session\SessionManager->startNow()
#2 /app/vendor/symfony/http-foundation/Session/Session.php(59): Drupal\Core\Session\SessionManager->start()
#3 /app/docroot/core/modules/big_pipe/src/Render/BigPipe.php(240): Symfony\Component\HttpFoundation\Session\Session->start()
#4 /app/docroot/core/modules/big_pipe/src/Render/BigPipe.php(295): Drupal\big_pipe\Render\BigPipe->performPreSendTasks()
#5 /app/docroot/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(423): Drupal\big_pipe\Render\BigPipeResponse->sendContent()
#7 /app/docroot/index.php(20): Symfony\Component\HttpFoundation\Response->send()
#8 {main}

And access denied for the physical remote browser path for the file.

When uninstalling the Big Pipe module the PHP error with response goes a way
But the Access denied stays

Proposed resolution

  • Perform an IO check before pushing the image to the source in the browser.
  • Request a response from the JS behavior to create the image (with another hidden namespace).
  • Pass the physical image path to the source, only when it physical file is ready

Remaining tasks

  • βœ… File an issue
  • βž– Addition/Change/Update/Fix
  • βž– Testing to ensure no regression
  • βž– Automated unit testing coverage
  • βž– Automated functional testing coverage
  • βž– UX/UI designer responsibilities
  • βž– Readability
  • βž– Accessibility
  • βž– Performance
  • βž– Security
  • βž– Documentation
  • βž– Code review by maintainers
  • βž– Full testing and approval
  • βž– Credit contributors
  • βž– Review with the product owner
  • βž– Release notes snippet
  • ❌ Release

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A
πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡―πŸ‡΄Jordan Rajab Natshah Jordan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024