Skip to content

fix(dapp-factory): remove illegal await in constructor and fix exit code#246

Open
0xAxiom wants to merge 1 commit intomainfrom
fix/async-constructor-and-exit-code
Open

fix(dapp-factory): remove illegal await in constructor and fix exit code#246
0xAxiom wants to merge 1 commit intomainfrom
fix/async-constructor-and-exit-code

Conversation

@0xAxiom
Copy link
Copy Markdown
Owner

@0xAxiom 0xAxiom commented May 1, 2026

What

Two bugs in dapp-factory/ that cause runtime failures:

1. await inside a synchronous constructor (guaranteed crash)

dapp-factory/pipeline/web3_pipeline.ts used await import('crypto') inside Web3Pipeline's constructor, which is not async. This is illegal in TypeScript/JavaScript — constructors cannot await. The expression resolves to a Promise at runtime, meaning .createHash() would be called on a Promise object instead of the crypto module, crashing every new Web3Pipeline(...) call.

Fix: Add a static top-level import * as crypto from 'crypto' (Node.js built-in, no dynamic load needed) and remove the dynamic import line.

2. main().catch(console.error) swallows the exit code

dapp-factory/web3factory.ts ended with main().catch(console.error), which logs the error but exits with code 0. Any caller (CI, shell scripts) would see success even on failure.

Fix: Changed to main().catch(err => { console.error(err); process.exit(1); }).

Why

  • Bug 1 causes new Web3Pipeline() to throw a TypeError on every invocation — the dApp pipeline can't start at all.
  • Bug 2 means broken runs are invisible to CI and callers.

Tested

  • dapp-factory/ TypeScript compiles without errors after the import change.
  • Lint and format pass (verified via pre-commit hooks).

🤖 Generated with Claude Code

- Replace dynamic `await import('crypto')` in Web3Pipeline constructor
  with a static top-level import; constructors cannot be async so the
  dynamic import was a guaranteed runtime crash.
- Fix `main().catch(console.error)` in web3factory.ts to call
  `process.exit(1)` on rejection so CI and callers receive a non-zero
  exit code on failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@0xAxiom 0xAxiom requested a review from MeltedMindz as a code owner May 1, 2026 04:06
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