# Loop without a reachable exit

Source: https://findproxyforurl.net/rules/potentially-infinite-loop/ · last updated 2026-10-11

Rule PAC-E008 (`potentially-infinite-loop`), severity high, category: Errors and robustness.

A while/for/do loop whose condition is a constant truthy value and whose body contains no break, return or throw. It can never terminate.

## Why it matters

`while (true)` or `for (;;)` without `break` or `return` inside is the static form of
PAC-E007. It is usually a leftover from debugging or a mis-edited retry loop. Unlike most
PAC bugs this one does not fail open; it stalls proxy resolution for the whole browser.


## How to fix

Delete the loop or add a terminating condition; PAC logic rarely needs loops at all.

## Bad

```js
function FindProxyForURL(url, host) {
  while (true) {
    host = host.toLowerCase();
  }
  return "DIRECT";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  host = host.toLowerCase();
  return "DIRECT";
}
```

## Engine behaviour

- winhttp: An endless loop was not stopped: it blocked the calling program for more than 18 minutes and kept running after that program was ended. (source: lab, verified 2026-10-11)
