Sporadic/Intermittent issues with node js

Hi All,

I came across a scenario where a proxy is developed using mostly node js.

So, while running the same using postman the result is sporadic.

For eg. out of 10 runs I get 3-4 times "500 Internal Sever Error",

{ "fault": { "faultstring": "Script node executed prematurely:..............

.................................

.....................,

"detail": { "errorcode": "scripts.node.runtime.ScriptExitedError" }

}

}

Solved Solved
0 3 259
1 ACCEPTED SOLUTION

ScriptExitedError

means your script exited.

This often happens if you have a runtime exception in your code, which is not caught.

Uncaught exceptions will lead to the script exiting.

To address this, track down and handle the uncaught exception.

Eg, you may wish to add something like this to your nodejs module to document WHERE the code is getting an exception.

process.on('exit', function (code) {
   console.log('Script terminating with code %s', code);
});
process.on('uncaughtException', function (err) {
    console.log(err.stack);
});

That won't solve the problem, but it will help you identify the source of the problem.

BTW, To actually SEE the output of these handlers, you need to look into the nodejs logs. Use the Apigee Admin UI to view those.

View solution in original post

3 REPLIES 3

ScriptExitedError

means your script exited.

This often happens if you have a runtime exception in your code, which is not caught.

Uncaught exceptions will lead to the script exiting.

To address this, track down and handle the uncaught exception.

Eg, you may wish to add something like this to your nodejs module to document WHERE the code is getting an exception.

process.on('exit', function (code) {
   console.log('Script terminating with code %s', code);
});
process.on('uncaughtException', function (err) {
    console.log(err.stack);
});

That won't solve the problem, but it will help you identify the source of the problem.

BTW, To actually SEE the output of these handlers, you need to look into the nodejs logs. Use the Apigee Admin UI to view those.

Hi @Dino-at-Google

Even I'm facing the same intermittent issue. The node proxy was running fine till this time.

I see the following in from Node.js logs

*** Starting script *** syntax error syntax error at module.js:439 at module.js:474 at module.js:356 at module.js:312 at module.js:497 at startup (trireme.js:142) at trireme.js:923

I think your issue is COMPLETELY DIFFERENT.

Your problem appears to be that you're using a dependency that is not compatible with trireme, which requires node 0.10.32.

If you use ES6 or any npm module that uses ES6, you will see this error at runtime. It is completely different than the original proiblem reported here.

Check your dependencies. Search the community archive for more information.

ps: I moved your comment to a COMMENT. You had originally posted it as an ANSWER. It's not an answer.