Working on a macro as part of Codegeist, we noticed that sometimes AP.context wasn’t available in our Connect Iframes. As a result, whenever this happens, our macro, macro editor, or any other Connect Iframes on that pages were completely broken.
Reproducing the error is as simple as this:
Going to a Confluence page.
Opening the editor.
Letting everything load, mouving your mouse, maybing typing something…
We’ve been able to reproduce this on several different Cloud instances, using different computers and browsers. Sometimes the ac/context missing ac/content-resolver error even appeared out of the blue without explicitly reloading.
I just confirmed this. I don’t think it’s affecting our macros only because we aren’t using AP.context. But it seems like a significant bug in the big picture.
Thanks for raising this @sven.schatter and going to the trouble of creating a really clear demo. ac/context is the module that implements the AC.context API which is injected into the iframe. It depends on the ac/content-resolver module to fetch context information from the server. I don’t know why the ac/content-resolver module isn’t available, but I notice that it is only defined after the global object connectHost has been defined. I’ll chase it up on Monday morning.
Regards,
Dugald
This has been hitting my users for weeks now. I added a wait function that stopped execution until !!AP.context. That reduced the error count, but now users get AP.context.getToken === undefined instead.
Well, you’re right, but the point stands that (AFAIK) AP should be fully loaded at that point, since AJS.toInit is a wrapper for $(document).ready. But in fact AP components seem to get loaded asynchronously and thus are frequently missing when needed.
Yeah, there’s no formal relationship between AJS and AP. AJS is the JavaScript library that supplements AUI which is the pre-cursor to AtlasKit. The API provided by the AP object is detailed in the JavaScript API section of the documentation and is referred to as Atlassian Connect JavaScript (ACJS). Some of ACJS is open source and you can see it depends on AJS to perform certain UI actions such as creating flags and dialogs. ACJS has been updated to allow for an AtlasKit implementation of the various UI interactions, but this requires adoption by Jira and Confluence which is still pending.
For those of you sweating on this issue, a fix has been proposed and now needs to be reviewed. With any luck, it may be available early to mid next week.