fix: replace illegal await-in-constructor with static crypto import (Web3 Factory broken)#240
Open
fix: replace illegal await-in-constructor with static crypto import (Web3 Factory broken)#240
Conversation
The Web3Pipeline constructor used 'await import("crypto")' which
throws SyntaxError: Unexpected reserved word at runtime because
constructors are synchronous and cannot use await. This broke the
entire Web3 Factory pipeline on any invocation.
Fix: add 'import * as crypto from "crypto"' at the top of the file
(matching the pattern already used in prompt_enforcer.ts) and remove
the dynamic import. No behaviour change — crypto is a built-in module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix a
SyntaxErrorthat prevents the Web3 Factory (web3 idea <IDEA>) from starting.Root Cause
dapp-factory/pipeline/web3_pipeline.tsusesawait import('crypto')inside theWeb3Pipelineclass constructor:At runtime Node.js throws:
This crashes the process before any pipeline stage runs.
Why it wasn't caught by TypeScript:
dapp-factory/tsconfig.jsonexcludespipeline/**from compilation, so the compiler never saw this file.Fix
Replace the illegal dynamic import with a static import at the top of the file — consistent with
prompt_enforcer.ts, which already usesimport * as crypto from 'crypto':No behaviour change.
cryptois a Node.js built-in; static import is equivalent and synchronous.Tested
npm test— 252/252 tests pass ✅