Created a Zephyr (ZAPI) Plugin - Macro Contents don't display when exporting to PDF (timeout)

We use Jira with the Zephyr plugin to manage test executions and ZAPI to allow us to access Zephyr data though an API.

I have created a Confluence plugin that allows users to insert a macro, specifying a ZQL query to run in Zephyr through API to obtain a number of results based on name, version, etc.

At first, I was using a Static Content Macro and this worked fine when the query was simple and was able to return data in under 10 seconds. However, with larger queries, it could take upwards of 40 seconds to complete. With a Static Content Macro, confluence will time out after a threshold set in Settings > General Configuration > Connection Timeouts. These fields are not editable, I believe because we are using Cloud.

So I changed it to be a Dynamic Content Macro. Confluence would load up and execute the macro in a sort of frame and it was able to perform the query at its own pace. All seemed good.

Then we tried to export a page (using the “Scroll” plugin) with this macro and nothing showed up. I learned about RenderModes and specified that when exporting to a PDF, it should also use the same URL it used to render the page. For smaller queries (taking less than ~10 seconds), this worked fine and the macro output showed up in the PDF. But for larger queries (which we will need), the PDF export gives up on rendering the macro after about 10 seconds, which is the result of the same parameters giving issues with the Static Content Macros.

We really want to be able to use the Scroll plugin to export as it allows us to take advantage of templates created there. But if that plugin will always bail after 10 seconds when trying to render a macro when exporting, it won’t work.

But what if we didn’t try to render the macro when exporting? What if the user loads the page, the macro runs, executes the query, then stores the results somewhere, caches it maybe? Then, when exporting, I could use the “renderModes” parameter for “pdf” to point to the cached version. Is this possible? And, if so, any idea how it might be accomplished? If it’s not possible, are there any other solutions to this?

Thanks,
Jeremy