Skip to content

fix(cu/hb): fix slot increment string concat and remove dryRun body guard#1295

Open
atticusofsparta wants to merge 1 commit intopermaweb:feat/hb-unitfrom
atticusofsparta:feat/hb-unit
Open

fix(cu/hb): fix slot increment string concat and remove dryRun body guard#1295
atticusofsparta wants to merge 1 commit intopermaweb:feat/hb-unitfrom
atticusofsparta:feat/hb-unit

Conversation

@atticusofsparta
Copy link

Summary

Two bugs in servers/cu/src/effects/hb/index.js that cause compute failures after restart or checkpoint recovery when running as a HyperBEAM CU:

  • String concatenation in slot increment: from = from + 1 performs string concatenation instead of numeric addition because fromOrdinate is coerced to a string via z.coerce.string(). After nonce ~438779 this produces '4387791' instead of 438780, causing all subsequent message fetches to request the wrong slot range and stalling compute indefinitely. Fixed with parseInt(\${from}`) + 1` (matching the pattern already used on line 536).

  • dryRun guard throws unconditionally on normal compute paths: if (!dryRun) throw fired for all non-dry-run calls because dryRun is undefined (not false) in readResultWith — and !undefined === true. This prevented the scheduler fallback fetch from running whenever the local body was stale or missing, breaking recovery after restart. Removed the guard so the fallback to fetchPageDataloader.load() always runs when the body is invalid.

Test plan

  • Verified both fixes applied to a running HyperBEAM node; process computed from checkpoint nonce 1984 through slot 682,000+ without stalling
  • Verified node recovers correctly after genesis-wasm restart (serves from SQLite cache, rebuilds in-memory WASM, continues computing)
  • Unit tests for loadMessagesWith covering string-typed from values and undefined dryRun

🤖 Generated with Claude Code

…uard

Two bugs in the HyperBEAM CU effects layer that cause compute failures
after restart or checkpoint recovery:

1. `from = from + 1` performed string concatenation instead of numeric
   addition because `fromOrdinate` is coerced to string via `z.coerce.string()`.
   After nonce ~438779 this produces `'4387791'` instead of `438780`,
   causing all subsequent message fetches to request the wrong slot range.
   Fixed by wrapping in `parseInt(\`${from}\`)`.

2. `if (!dryRun) throw` fired unconditionally for normal (non-dry-run)
   compute paths because `dryRun` is `undefined` in `readResultWith` calls,
   and `!undefined === true`. This prevented the scheduler fallback fetch
   from running whenever the local body was stale or missing, breaking
   recovery after restart. Removed the guard so the fallback always runs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant