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

Errors are logged when the client cancels a request answered with the rawResponse Velocity macro

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      Steps to reproduce

      1. Open a page doing an AJAX request answered with the #jsonResponse or #rawResponse Velocity macros, e.g. a page displaying a document tree (such as the Menus administration section)
      2. Leave the page before the response is received (e.g. click on a link while the tree is loading)

      Expected

      Nothing is logged: the client cancelled the request.

      Actual

      Errors without any cause are logged:

      ERROR o.a.v.d.null - Exception in macro #rawResponse called at <unknown template>[line 3092, column 1]
      ERROR o.a.v.d.null - Exception in macro #jsonResponse called at xwiki:XWiki.DocumentTreeMacros[line 82, column 1]
      ERROR o.a.v.d.null - Exception in macro #handleDocumentTreeRequest called at xwiki:XWiki.DocumentTree[line 3, column 1]
      

      Analysis

      #rawResponse writes the content directly to the HTTP response and flushes it. When the client has closed the connection in the meantime, this fails with IOException: Broken pipe (checked by catching the exception in an instrumented #rawResponse). Velocity logs an error without the exception for each macro the exception goes through, then the velocity macro of the page renders an inline error which is not received by anyone. XWikiAction already ignores such aborted connections (logged at debug level), but the exception doesn't reach it.

      Proposed fix: in #rawResponse, catch the failure to send the response: log it at debug level when it's caused by an IOException (the client is gone), as a warning with the exception otherwise.

      Found in the logs of MenuIT in the MySQL environment of the XWiki Environment Tests job on CI (master builds 1406 and 1409, the environment running the WCAG validation, which makes the tests leave pages while the document tree is still loading), and reproduced locally with the same setup.

      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: