Problem/Motivation

While indexing a page I get an error "RuntimeException while trying to render item entity:node/10006:de with view mode search_index for search index Index A: Failed to start the session because headers have already been sent by "/app/vendor/symfony/http-foundation/Response.php" at line 1285. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 116 of /app/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php)."

The stack trace indicates this starts in CookiePreviewDetector::isPreviewing method.

#0 /app/docroot/core/lib/Drupal/Core/Session/SessionManager.php(129): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
#1 /app/docroot/core/lib/Drupal/Core/Session/SessionManager.php(94): Drupal\Core\Session\SessionManager->startNow()
#2 /app/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php(282): Drupal\Core\Session\SessionManager->start()
#3 /app/vendor/symfony/http-foundation/Session/Session.php(201): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag('attributes')
#4 /app/vendor/symfony/http-foundation/Session/Session.php(221): Symfony\Component\HttpFoundation\Session\Session->getBag('attributes')
#5 /app/vendor/symfony/http-foundation/Session/Session.php(69): Symfony\Component\HttpFoundation\Session\Session->getAttributeBag()
#6 /app/docroot/modules/contrib/entity_reference_preview/src/Plugin/PreviewDetector/CookiePreviewDetector.php(51): Symfony\Component\HttpFoundation\Session\Session->get('entity_referenc...')
#7 /app/docroot/modules/contrib/entity_reference_preview/src/Cache/StatusPreviewCacheContext.php(68): Drupal\entity_reference_preview\Plugin\PreviewDetector\CookiePreviewDetector->isPreviewing(Object(Symfony\Component\HttpFoundation\Request))
#8 [internal function]: Drupal\entity_reference_preview\Cache\StatusPreviewCacheContext->Drupal\entit

Steps to reproduce

Set up Search API.
Enable this module.
Used the rendered output plugin in your search index.
Check the logs.

Proposed resolution

We should check that the session is actually started before trying to access the cookie. That gets rid of the error for me. If it hasn't just return FALSE. I don't think returning FALSE really matters in search index because you only want to render default revision content.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

achap created an issue. See original summary.

achap’s picture

Assigned: achap » Unassigned
Status: Active » Needs review

steven jones made their first commit to this issue’s fork.

steven jones’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! LGTM.

  • steven jones committed 6b3b2e9d on 1.x authored by achap
    fix: #3605600 "Failed to start the session because headers have already...
steven jones’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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