XPages SSJS will run forever if you let it

If you add some code behind a button, and a user clicks that button. This code will run until it’s finished no matter what you do.

var LoopBreak=0;var x=0
var thing=1
var now=@Text(@Now())
var nownow=""
for(x=0;x<10000;x++){ nownow=@Text(@Now()) } if(LoopBreak>30){

If you place the code above behind a button on an XPage.

(Of couse at your own risk, and not on a production server)

Open the XPage in a webbrowser, also open up so you can watch the server console in realtime.

Click on the button and close the browser window directly afterwards, and watch the server console.

The code will continue to run until it’s done, imagine what will happen if you remove the line LoopBreak++  you will get a infinite loop.

And the CPU of your server will boost up to 100% and you will not be able to stop your Domino server with out killing it.

So my tip to you is to always have a fail safe, a loop breaker for your loops.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.