Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25431

An error is logged when the client cancels a request answered with an error page

    XMLWordPrintable

Details

    • Unknown
    • N/A
    • N/A

    Description

      Steps to reproduce

      Request a missing attachment (e.g. an image whose attachment doesn't exist, displayed in an editor) and close the connection before XWiki has sent the response, for example by leaving the page or by having the browser cancel the image request.

      Result

      The following error is logged:

      ERROR c.x.x.w.XWikiAction - Connection aborted. Root cause is [IOException: Connection reset by peer]
      

      or, depending on how the connection was closed:

      ERROR c.x.x.w.XWikiAction - Connection aborted. Root cause is [IOException: Broken pipe]
      

      Similarly, when an action fails because the client closed the connection with a "Connection reset by peer", the failure is logged at warning level with its stack trace (Uncaught exception), while a "Broken pipe" is not logged.

      Expected

      Nothing is logged at error or warning level: the client closing the connection is not an error of the server and there's nothing the server can do about it.

      Analysis

      In XWikiAction#execute(), when the action fails with an error that is answered with an error page (e.g. ERROR_XWIKI_APP_ATTACHMENT_NOT_FOUND, answered with the attachmentdoesnotexist template), and sending this page fails because the client closed the connection (ERROR_XWIKI_APP_SEND_RESPONSE_EXCEPTION), the failure is logged at error level. XWIKI-7408 lowered the same "Connection aborted" log to debug level when the action itself fails to send the response, but not this one.

      Besides, before logging an uncaught exception at warning level, XWikiAction#execute() skips the ones caused by the client closing the connection by comparing the root cause message with IOException: Broken pipe only: depending on whether the client reset the connection, the servlet container reports a broken pipe or a connection reset.

      Seen in the functional tests: ImageIT (CKEditor and BlockNote) logs it on the download of missing.png and image.gif in almost every build, in every environment of the XWiki Environment Tests job. The "Broken pipe" variant is registered as a global expected line in LogCaptureValidator; the "Connection reset by peer" variant was logged on PostgreSQL in XWiki Environment Tests build 1410. Found while assessing the impact of failing functional tests on ERROR logs again.

      Related to XWIKI-25428, the same kind of problem in the rawResponse Velocity macro.

      Proposed fix

      • Log the failure to send the error page at debug level, like the failure to send the response.
      • Skip both the broken pipe and the connection reset root causes before logging an uncaught exception.

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: