In this case, definitely read through all the bug reports I’ve made (https://squizmap.squiz.net/matrix/_reports/contributed?creatorOR=-1374); you’ll likely encounter all of those bugs because you’re on such an early version of SSJS support. If you’re able to upgrade Matrix, definitely try and do so first.
In terms of debugging, if you can, turn off hiding of front end errors and again, if you can, access the system’s error log. In my case, I have access to do neither because we only have a production environment so I use the ?SQ_DISABLE_SERVER_JS
query string (https://matrix.squiz.net/manuals/concepts/chapters/server-side-javascript#disabling-ssjs) which causes all the SSJS to just dumped into the page sent to your browser. You can then use your browser’s debug console to pinpoint problems. It’s fiddly but you can get by if you ensure your keyword use, if present, still makes for valid JavaScript.
With our hosted setup, there’s been ambiguity around exactly what version of JavaScript (eg through V8Js) was being run so I found that writing an SSJS ‘introspector’ (eg using JS’s Object.getOwnPropertyNames(global)
where global
is the global object) was extremely helpful in determining what objects and functions exist in our environment. Overall, I determined our setup was somewhere between ECMAScript 5.1 and 6 – certain syntax from 6 works but most doesn’t; YMMV.