soma.cell

E0093: every_zero

E0093 every_zero — every 0 — an interval must be positive.

A compile-time error of soma check, the checker of the Soma programming language (soma explain E0093).

The rule

An every block needs a positive interval: every 0s (or 0ms, 0min) would run its body back to back for as long as the server is up, so soma check refuses it with E0093. The message names the interval in milliseconds whatever unit you wrote. Give the block the period you actually mean, such as every 1min, with a unit among ms, s, min, h, d.

A program that triggers it

wrong.cell

cell Sessions {
    face {
        signal expire_idle() -> Int
    }
    memory {
        last_seen: Map<String, Int> [persistent]
    }
    on expire_idle() {
        let cutoff = now() - 1800
        for user in last_seen.keys {
            if (last_seen.get(user) ?? 0) < cutoff {
                last_seen.delete(user)
            }
        }
        return last_seen.size
    }
    every 0s { expire_idle() }
}

What soma check prints:

$ soma check wrong.cell
error: `every 0ms` would run its body back to back, forever — give it a period of at least 1ms
  --> wrong.cell:17:5
   |
17 |     every 0s { expire_idle() }
   |     ^
  = code: E0093
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: give it a period of at least 1ms

On line 17, every 0s { expire_idle() } becomes every 1min { expire_idle() }.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -15,4 +15,4 @@
         return last_seen.size
     }
-    every 0s { expire_idle() }
+    every 1min { expire_idle() }
 }

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.