Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Try/catch behavior in batch.js

Scott Martindale April 28, 2023

I'm writing a P2 plugin for Confluence. This code transforms a .js file on the fly using the Web Resource Transformer. Everything works absolutely perfectly in a barely-configured developer plugin instance (created from running `atlas-debug`), but when I connect to a real staging server (highly configured & customized with many plugins). Version numbers don't seem to be an issue, since if I match the staging servers' version numbers, I observe the same result. But in any case, I've tried with both 7.19.8 and 7.13.7.

On the development environments, I see something like this:

/* module-key = 'confluence.extra.jira:web-resources', location = 'templates/extra/jira/jiraIssues.js' */


{code...}

;

On the two staging servers, I observed identical behavior:

try{ 
/* module-key = 'confluence.extra.jira:web-resources', location = 'templates/extra/jira/jiraIssues.js' */


{code...}

}catch(e){WRMCB(e)};
;

This try/catch code block is repeated for each of the scripts that are being compiled (100s of times). The issue I see is that on the staging servers, `}catch(e){WRMCB(e)}` to close out the try/catch block never comes, so it fails. I want to find out what is generating these try/catch code blocks to see if I can find some reference or perhaps even support, but my searches so far are coming up empty. 

Here is the relevant portion of the atlassian-plugin.xml 



<web-resource key="js-transform-javascript">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<transformation extension="js">
<transformer key="js-transformation" />
</transformation>
<resource type="download" name="/js/js-mod.js" location="/js/js-mod.js" />
<context>atl.general</context>
</web-resource>
<web-resource-transformer key="js-transformation" class="com.example.app.jsTransformer" />

Two final notes: when I examine the failing code, I can observe that the correct transformation has taken place. And when I manually append the closing code fragment, the javascript loads without errors:

}catch(e){WRMCB(e)};
;

 

1 answer

1 accepted

2 votes
Answer accepted
Scott Martindale April 30, 2023

It turns out that the "WRMCB" refers to the Web Resource Manager Catch Block. It's part of production environments, but for obvious reasons, it's disabled by default in Dev Environments. If you need to enable this to debug the functionality (or your plugin in a test environment) you can do so using the following command:

atlas-debug -Dplugin.webresource.javascript.try.catch.wrapping=true

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.19.8
TAGS
AUG Leaders

Atlassian Community Events