Infinite loops in BPM show up as either a BPD that never ends (a loop back that always fires) or a service that spins (a JavaScript while that never exits, a service calling itself). How to find them:
- Instance level: Process Admin > Process Inspector / Process Instances: an instance with thousands of completed steps, or the same activity appearing over and over in the execution tree (GET /rest/bpm/wle/v1/process/{piid}?parts=executionTree). The PDW / Performance data shows the activity count per instance.
- Event manager: a looping system step keeps re-scheduling itself - Process Admin > Event Manager > Monitor shows a queue that never drains, and event manager tasks that re-appear for the same instance every few seconds.
- JVM level: a service in a tight loop pins a thread - take three javacores 30 seconds apart (kill -3 <pid> or wsadmin AdminControl.invoke(jvm, 'dumpThreads')) and look for a WebContainer / EM thread that stays in the same Rhino frame (org.mozilla.javascript) each time; the frame names contain the service id. IBM Thread and Monitor Dump Analyzer makes this a two-minute job.
- Hung-thread detection: WebSphere logs WSVR0605W: Thread ... has been active for ... milliseconds and may be hung with a stack - set com.ibm.websphere.threadmonitor.threshold to catch loops early.
- Design-time: the validation panel warns about BPD loops without exit conditions only in obvious cases; review every "loop back" sequence flow for a condition that can become false, and every while in scripts for the increment.
// safe loop pattern in a script task
var guard = 0;
while (hasMore && guard++ < 10000) { hasMore = fetchNextPage(); }
if (guard >= 10000) throw new Error("Loop guard hit - aborting");Stopping a running one: Process Admin > instance > Suspend then Terminate (or the REST PUT /process/{piid}?action=terminate); a thread stuck in a script needs a JVM restart of that member - BPM cannot interrupt a Rhino loop.
References