Code Block Macro Hanging, how to resolve?
Asked by James Rinkevich:

Code Block Macro will spin (hang) when invoked explicitly such as by clicking the edit button. Partial work-arounds are available using {code


Answers:
author: Tom Svaleklev
body: We have exactly the same problem with the Code Block macro only. Please advise as we are not able to use it at all.

Confluence version: 6.15.6

comments: author: Tom Svaleklev
body: We spotted the problem in our case and it had to do with a totally different plug-in we are using named Linchpin Events. An upgrade was available and once applied our problems went away.

Very unclear why Linchpin Events was in play at all on our offending page(s) where the Code Block macro was used, but no macros from Linchpin?


author: Shannon S
body: Tom,

Thank you for letting us know about that. It could be that there's something running in the background from Linchpin Events that is causing this. I would also recommend [contacting Linchpin](mailto://help@seibert-media.net) to see if this is a known issue on their end.

Let me know if you have any trouble.

Regards,

Shannon


author: Tom Svaleklev
body: I have informed Linchpin (Seibert Media)


author: Shannon S
body: Tom,

Thank you for confirming that! Take care, and have a pleasant rest of your week.

Regards,

Shannon


author: Tom Svaleklev
body: Linchpin fed back and confirmed that their patch that we applied was a bug fix of this exact case so they were aware.


author: Shannon S
body: Tom,

That's great, thank you so much for the update!

Have a pleasant weekend.

Regards,

Shannon


author: James Rinkevich
body: Entered: <https://getsupport.atlassian.com/servicedesk/customer/portal/14/CSP-261735>  
This is a short week. We had Columbus day on Moday and tomorrow, our 5-4-9 Friday off, however, I entered this through my gmail account so I could see it when I wasn't at wasn't at work given we're on GMT-0700 aka PDT (Los Angeles time zone).

comments: author: James Rinkevich
body: I enterred the support ticket at <https://getsupport.atlassian.com/servicedesk/customer/portal/14/CSP-261735>


author: Shannon S
body: Hi James,

Thank you for confirming that.

I see my colleague replied to you before I had a chance to update the case with your details. Feel free to reply there with a copy of your HAR file and Support zip. I want to be able to confirm that you are indeed encountering the issue in the bug.

Thank you for your help.

Regards,

Shannon


author: Shannon S
body: Hi [@James Rinkevich](/t5/user/viewprofilepage/user-id/3557659),

I see that your case with the support team is about to timeout since we haven't heard from you recently with a copy of your HAR file and support zip. You'll want to reply in the next day or so to avoid that happening! Let me know if you're having any trouble uploading files to the support portal.

Regards,

Shannon


author: Shannon S
body: Hello James,

Welcome to Atlassian Community. It's nice to meet you.

You'll want to have a look at your [Confluence Server logs](https://confluence.atlassian.com/doc/working-with-confluence-logs-108364721.html) as well as what's going on in the Developer Tools \> Network console of your browser. This should tell you what it's hanging on.

You can feel free to share any messages you encounter there, as well as which version of Confluence you are running, and I can help you to determine the issue.

Regards,

Shannon

comments: author: James Rinkevich
body: OK looked at the server logs nothing was there but the developer tools have a failure to load plugin from http://server:port/\<rest of plugin url\> and I'm certain the server does not respond to http: as that is considered an insecure protocol.


author: Shannon S
body: James,

Can you verify that your base URL isn't set to the http version? It seems odd that the code macro would try to be accessing your site from that protocol.

Regards,

Shannon


author: James Rinkevich
body: looking at the Confluence administration page, Under CONFIGURATION in the general administration section the Server Base URL is set to https://\<server_confluence_host_name\>:\<port\>   
Also under administration in system information it shows the same Server Base URL


author: Shannon S
body: Thank you, James.

I suspect you might be running into this bug:

* [CONFSERVER-57934](https://jira.atlassian.com/browse/CONFSERVER-57934) *Adding panel,excerpt,warning,note,tip or info macro to the page in edit mode will trigger mixed content action in browser*

Specifically, it mentions the info, etc. macros, but it has affected other macros, such as the code block macro. This would depend on your version of Confluence, but it's been affecting the latest versions.

There's a workaround you can apply that has helped some users listed on the ticket. Could you give that a try and let me know if corrects the issue? If not, I would ask that you can record the behaviour into a [HAR File](https://confluence.atlassian.com/kb/generating-har-files-and-analyzing-web-requests-720420612.html) so we can have a deeper look.

Regards,

Shannon


author: James Rinkevich
body: I tried to load the java script but either I did not load it in the proper area or it didn't work. BTW this happens in both IE11/Win10 and Chrome.


author: Shannon S
body: James,

Can you let me know where you added the javascript, and your exact version of Confluence?

Regards,

Shannon


author: James Rinkevich
body: 1. I tried adding the script on the page where I was using the code block macro. Should I have added it to the Custom HTML on the Look and feel tab of the administration page  
2. We have Confluence v7.01 installed.


author: Shannon S
body: Hi James,

The workaround says that it should be added in the Custom HTML section.
>
> ### Workaround {#toc-hId-1110302861}
>
> Some users have found the below custom HTML resolves the issue in Chrome:
>
Copy text/code below into **BODY** section of **Configuration --\> Custom HTML**  
>
> ```
> <script type="text/javascript">  function fixFrameContent(frameContent, broken_url_prefix) {    var replaced = false;    // Replace broken img src urls    frameContent.find("img").each(function(index) {      var srcUrl = AJS.$(this).attr("src");      if (srcUrl.toLowerCase().startsWith(broken_url_prefix)) {        var srcNewUrl = srcUrl.substring(broken_url_prefix.length);        AJS.$(this).attr("src", srcNewUrl);        replaced=true;      };    });  // each img         // Replace broken tables for macro - background img url is broken    // Iterate over all relevant tables to check background-image URL    frameContent.find("table.wysiwyg-macro").each(function(index) {      AJS.log(AJS.$(this));      var bgiRaw = AJS.$(this).css("background-image");      if (!bgiRaw) return true;  // nothing to do, continue with next element      // remove 'url(...)' around the content      var bgiUrlMatch = bgiRaw.match(/url\(["']?(.*)["']?\)/);      if (!bgiUrlMatch) return true;  // nothing to do, continue with next element      var bgiUrl = bgiUrlMatch[1];      if (bgiUrl.toLowerCase().startsWith(broken_url_prefix
> ```

Can you give that a try and let me know how it goes?

Regards,

Shannon


author: James Rinkevich
body: This didn't work. still get 400 errors that lead to code block macro spinning/hanging.


author: Shannon S
body: James,

Thank you for trying the workaround and confirming that it's not effective in your situation.

I'd like to raise a ticket for you in support, but I wasn't able to find a license associated with your email address. Could you confirm with me if you have a valid license currently?

Regards,

Shannon


Tags: confluence-server

server