Not a bug Server error if Elasticsearch is not running

AndyB

Well-known member
Affected version
Enhanced search v2.2.2
If Elasticsearch is not running and you try to do a search the following server error is displayed:

1638552489400.png

If Elasticsearch is not running, it would be better to return this error phrase:

return $this->error(\XF::phrase('xfes_elasticsearch_server_could_not_be_reached'));
 
Last edited:

Rasmus Vind

Well-known member
I believe XF only displays exceptions if DEBUG is enabled in your config.php. Otherwise it gives a less technical error.

Also. Normal users have no idea what ElasticSearch is and don’t care. All they need to know is that the page is temporarily unavailable.
 

webbouk

Well-known member
I believe that error would only show in the ACP therefore only visible to admins with the correct permissions
 

PaulB

Well-known member
The error shows on the front end to any logged in member but only if debug mode is enabled.
I was observing different behavior: the trace was showing even with debug mode disabled.

Looking at \XF\ControllerPlugin\Error::actionException, it seems the logic is to display the error if the site is in debug mode or the current visitor is an admin. Otherwise, a generic error with no trace will be displayed.
 

AndyB

Well-known member
I just checked and indeed if I'm logged in a normal registered user and Elasticsearch is not running, I get a proper message like this:

1643753020219.png
 

Jeremy P

XenForo developer
Staff member
I don't think we'll be making any changes here. There are a number of places which make calls that will throw if a connection to Elasticsearch cannot be established, and indeed the exception is only displayed to administrators or while in debug mode. This shouldn't occur under normal circumstances anyway.
 
Top