Uploaded image for project: 'Confluence Cloud'
  1. Confluence Cloud
  2. CONFCLOUD-60219

'HTTP 504 Gateway Time-out' when storage-to-view converting pages with many static connect macros

      Rendering of pages having many static connect macros (without caching) can cause a gateway timeout if the rendering takes longer than 60 seconds.

      We ran into this when one of our customers exported a single page having a lot of multi-excerpt macros (those are static connect macros).
      Calling the /contentbody/convert/export_view REST API apparently took longer than one minute so the gateway closed the connection.

      This is a critical issue for us, because customers don't think of timeouts when adding (connect) macros on their pages.

      Steps to reproduce:

      1. Install an addon providing a 'dummy' static content macro that sleeps three seconds (contact cli@atlassian.com for this) 
      2. Insert 20 of the dummy macros into a Confluence page. Alternatively, POST the following JSON containing twenty of these macros to <your- site>/wiki/rest/api/contentbody/convert/export_view
        {
            "value" : "<p>before</p> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <ac:structured-macro ac:name=\"dummy\" ac:schema-version=\"1\" ac:macro-id=\"c9a41198-7f37-4009-842f-d263f02409d6\"/> <p>after</p>",
            "representation" : "storage"
        }
      1. You'll run into a '504 Gateway Time-out' after exactly one minute.

      Investigation Results: 

      I think the problem is that currently the Confluence page waits for all macros on the page to send back a response before rendering all of them. Because of this, when one macro times out, the entire page cannot be rendered.

      Solution:

      Refer to Steven's comment. 

            [CONFCLOUD-60219] 'HTTP 504 Gateway Time-out' when storage-to-view converting pages with many static connect macros

            This was fixed some time back.

            Ashish Shirode added a comment - This was fixed some time back.

            jens can you give us information on the confluence site in which this happened? 

            Cassandra Li (Inactive) added a comment - jens can you give us information on the confluence site in which this happened? 

            Hi sluthra@atlassian.com, this still happens and is not related to the editor version, but to the fact that static connect macros block the content rendering until they respond.

            Jens Rutschmann [K15t] added a comment - Hi sluthra@atlassian.com , this still happens and is not related to the editor version, but to the fact that static connect macros block the content rendering until they respond.

            tanstett is it still happening? Is it specific to old editor?

            Shreshth Luthra (Inactive) added a comment - tanstett is it still happening? Is it specific to old editor?

            Hi slancashire - how does the Confluence PDF Exporter deal with this situation?

            Tobias Anstett (K15t) added a comment - Hi slancashire - how does the Confluence PDF Exporter deal with this situation?

            I think we can add a timeout into the static macro render, both for a total static macro render time and for each individual macro. This should prevent an individual macro from being able to prevent the page from rendering, however the export wouldn't contain the content from the problematic macro/s.

            This will at least allow a user to see the problem is due to a particular macro or set of macros taking too long, and they can potentially rectify the problematic content themselves.

            Steve Lancashire (Inactive) added a comment - I think we can add a timeout into the static macro render, both for a total static macro render time and for each individual macro. This should prevent an individual macro from being able to prevent the page from rendering, however the export wouldn't contain the content from the problematic macro/s. This will at least allow a user to see the problem is due to a particular macro or set of macros taking too long, and they can potentially rectify the problematic content themselves.

              89741866c57b Ashish Shirode
              9a0e36f56f3a Jens Henrik Jens Henrik
              Affected customers:
              1 This affects my team
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: