Skip to content

fix(streams): parseStreamInfo must not throw on a malformed flags value (#617) - #688

Open
ZacLou wants to merge 3 commits into
conduit-protocol:mainfrom
ZacLou:fix/parse-stream-info-malformed-flags-617
Open

fix(streams): parseStreamInfo must not throw on a malformed flags value (#617)#688
ZacLou wants to merge 3 commits into
conduit-protocol:mainfrom
ZacLou:fix/parse-stream-info-malformed-flags-617

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Closes #617

When the contract returns a flags entry that is present but not a u32 ScVal, scValToU32 throws an unhandled Error. This change wraps the call in try/catch so parseStreamInfo defaults to 0 instead of letting the exception propagate.

Changes

  • Guard scValToU32(m["flags"]) with try/catch; malformed flags0.
  • Add unit test: a u64 ScVal passed as flags results in all flag booleans (paused, cancelled, clawbackEnabled) being false.

Checklist

  • Malformed flags no longer throws.
  • Test covers non-u32 ScVal type.

…tate (conduit-protocol#630)

Adds a lightweight CircuitBreaker that tracks failures per scope
(e.g. RPC URL). After a configurable threshold of consecutive failures,
the circuit opens and fast-fails subsequent calls with CircuitOpenError.
After a cooldown, the circuit transitions to half-open and allows a
single probe call.

- New src/circuit-breaker.ts: withCircuitBreaker, getCircuitState,
  CircuitOpenError, configureCircuitBreaker.
- createRpcServer now wraps every proxied method call through
  withCircuitBreaker scoped by rpcUrl.
- Exports added to src/index.ts.
- Unit tests cover closed/open/half-open states, success-reset, and
  CircuitOpenError scope propagation.
…ue (conduit-protocol#617)

When the contract returns a flags entry that is present but not a u32
ScVal, scValToU32 throws. Wrap the call in try/catch so parseStreamInfo
defaults to 0 instead of letting the unhandled exception propagate.

- Change const flags = m['flags'] ? scValToU32(...) : 0 to a guarded
  try/catch block that silently falls back to 0 on type mismatch.
- Add unit test: u64 ScVal passed as flags → all flag booleans false.
@ZacLou

ZacLou commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the CI failures:

  1. rollup.config.mjs did not include the new src/circuit-breaker.ts in manualChunks, so the build step failed to resolve the entry module.
  2. src/tests/circuit-breaker.test.ts had empty catch {} blocks that ESLint rejected. Added /* expected */ comments to satisfy the linter.

Local npm run typecheck, npm run lint (only pre-existing warnings remain), and npm test all pass. Quality gate passed.

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.

parseStreamInfo must not throw on a malformed flags value

1 participant