node package manager



slowpoke takes as input an AST generated by esprima and injects instrumentation code into all for, while and do loops encountered therein. Any loop which does not terminate after a user-specified timeout will throw an error.


Get it:

$ npm install slowpoke

Require it:

var slowpoke = require('slowpoke');


slowpoke(ast, options)

Modifies ast in-place such that all slow loops will throw an Error. ast must be an esprima-compatible AST structure.

Supported options:

  • timeout: number of milliseconds after which loop should abort. Default: 5000.


slowpoke only catches slow for, while and do loops - it cannot detect unbounded recursion.

Because slowpoke uses Error throwing as its abort mechanism, code containing try/catch may not function as intended. Future work could modify catch blocks re-raise errors thrown by slow loops.