We are getting the following error with NodeJS proxy on Private Cloud version 4.17.01. I am using the request and response modules. The same NodeJS code works in my Public Cloud trial org.
{
"fault": {
"faultstring":"Script node executed prematurely: syntax error\nsyntax error\n at module.js:439\n at module.js:474\n at module.js:356\n at module.js:312\n at module.js:497\n at startup (trireme.js:142)\n at trireme.js:923\n",
"detail":{
"errorcode":"scripts.node.runtime.ScriptExitedError"
}
}
}
Can you help how to debug this issue ?
-
Checked the Message Processor log (/opt/apigee/var/log/edge-message-processor/logs/system.log) and noticed the following exception and stack trace for the API request:
org.mozilla.javascript.EvaluatorException: syntax error (/organization/environment/api/index.js#22)
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77) ~[rhino-1.7.7.1.jar:1.7.7.1]
at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64) ~[rhino-1.7.7.1.jar:1.7.7.1]
at org.mozilla.javascript.Parser.addError(Parser.java:188) ~[rhino-1.7.7.1.jar:1.7.7.1]
at org.mozilla.javascript.Parser.addError(Parser.java:166) ~[rhino-1.7.7.1.jar:1.7.7.1]
...
-
This indicated that there is a syntax error at line # 22 of index.js file.
-
Checked the code at line # 22 in index.js :
}, (error, response, body) => {
-
The cause for syntax error is the use of “=>” in 4.17.01. However, this syntax is supported in Public Cloud which has the latest code.
-
Modified the code as follows:
}, function(error, response, body) {
With this change, I was able to resolve the error.
As far as i know, arrow functions are not supported on Private Cloud yet. They are a part of ES6 and we are still at ES5