Skip to content

fix: propagate ABCI errors instead of swallowing them#193

Merged
pyramation merged 3 commits intohyperweb-io:mainfrom
theforager:simulation-errors
Feb 28, 2026
Merged

fix: propagate ABCI errors instead of swallowing them#193
pyramation merged 3 commits intohyperweb-io:mainfrom
theforager:simulation-errors

Conversation

@theforager
Copy link
Copy Markdown
Contributor

Fixes #183

Issue

When simulation fails, abciQuery wasn't checking the ABCI response code. If fromBase64() happened to succeed on empty/garbage data, the error got swallowed entirely. Users end up seeing gasWanted: 0, gasUsed: 1000 with no idea why.

Fix

Check response['code'] !== 0 before trying to decode. If it's non-zero, throw an AbciError with the code and log message so callers can actually see what went wrong.

Added a new AbciError type to @interchainjs/types that includes the raw ABCI code and log:

try {
  await client.simulate(tx);
} catch (e) {
  if (e instanceof AbciError) {
    console.log(`code ${e.abciCode}: ${e.log}`);
  }
}

Changes

- packages/types/src/errors.ts - new AbciError class
- packages/utils/src/rpc.ts - check response code, use typed errors
- packages/utils/src/rpc.spec.ts - tests for error handling

Backward compatible since AbciError still extends Error.

@pyramation pyramation merged commit 28626f1 into hyperweb-io:main Feb 28, 2026
4 checks passed
@pyramation
Copy link
Copy Markdown
Contributor

Thank you!

@theforager theforager deleted the simulation-errors branch April 5, 2026 03:54
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.

simulateByTxBody seems broken. ABCI errors are swallowed

2 participants