Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Ganache Provider not considered valid by Web3 #290

Closed
adrianmcli opened this issue Jan 29, 2019 · 4 comments
Closed

Ganache Provider not considered valid by Web3 #290

adrianmcli opened this issue Jan 29, 2019 · 4 comments

Comments

@adrianmcli
Copy link
Contributor

When creating a Ganache provider and passing it into Web3, Web3 complains that it's not a valid provider. It fails on the second line here:

const provider = Ganache.provider();
const web3 = new Web3(provider);

More specifically, it fails on this line (in my reproduction repo): https://github.com/adrianmcli/repro-subscribe/blob/master/index.js#L11

This is the error call stack:

Error: Please provide an valid Web3 provider
    at ProviderResolver.resolve (/Users/adrianli/dev/repro-subscribe/node_modules/web3-providers/dist/web3-providers.cjs.js:720:13)
    at Web3.AbstractWeb3Module (/Users/adrianli/dev/repro-subscribe/node_modules/web3-core/dist/web3-core.cjs.js:27:51)
    at new Web3 (/Users/adrianli/dev/repro-subscribe/node_modules/web3/dist/web3.cjs.js:30:68)
    at main (/Users/adrianli/dev/repro-subscribe/index.js:13:16)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
Error: Please provide an valid Web3 provider
    at ProviderResolver.resolve (/Users/adrianli/dev/repro-subscribe/node_modules/web3-providers/dist/web3-providers.cjs.js:720:13)
    at Web3.AbstractWeb3Module (/Users/adrianli/dev/repro-subscribe/node_modules/web3-core/dist/web3-core.cjs.js:27:51)
    at new Web3 (/Users/adrianli/dev/repro-subscribe/node_modules/web3/dist/web3.cjs.js:30:68)
    at main (/Users/adrianli/dev/repro-subscribe/index.js:13:16)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

/Users/adrianli/dev/repro-subscribe/node_modules/solc/soljson.js:22
(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var __GLOBAL__I_000101=Module["__GLOBAL__I_000101"]=asm["__GLOBAL__I_000101"];var __GLOBAL__sub_I_ABIFunctions_cpp=Module["__GLOBAL__sub_I_ABIFunctions_cpp"]=asm["__GLOBAL__sub_I_ABIFunctions_cpp"];var __GLOBAL__sub_I_ABI_cpp=Module["__GLOBAL__sub_I_ABI_cpp"]=asm["__GLOBAL__sub_I_ABI_cpp"];var __GLOBAL__sub_I_ASTJsonConverter_cpp=Module["__GLOBAL__sub_I_ASTJsonConverter_cpp"]=asm["__GLOBAL__sub_I_ASTJsonConverter_cpp"];var __GLOBAL__sub_I_AST_cpp=Module["__GLOBAL__sub_I_AST_cpp"]=asm["__GLOBAL__sub_I_AST_cpp"];var __GLOBAL__sub_I_ArrayUtils_cpp=Module["__GLOBAL__sub_I_ArrayUtils_cpp"]=asm["__GLOBAL__sub_I_ArrayUtils_cpp"];var __GLOBAL__sub_I_AsmAnalysis_cpp=Module["__GLOBAL__sub_I_AsmAnalysis_cpp"]=asm["__GLOBAL__sub_I_AsmAnalysis_cpp"];var __GLOBAL__sub_I_CompilerContext_cpp=Module["__GLOBAL__sub_I_CompilerContext_cpp"]=asm["__GLOBAL__sub_I_CompilerContext_cpp"];var __GLOBAL__sub_I_Compiler
abort({}). Build with -s ASSERTIONS=1 for more info.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/adrianli/.npm/_logs/2019-01-29T15_45_27_098Z-debug.log

Possible Solution

I looked into the error "Please provide an valid Web3 provider" and tracked it down to this line: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-providers/src/resolvers/ProviderResolver.js#L98

That means this code block is not returning: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-providers/src/resolvers/ProviderResolver.js#L90-L96

Perhaps the instanceOf checks are not returning and the code path falls to the bottom.

Steps to Reproduce (for bugs)

Reproduction repo: https://github.com/adrianmcli/repro-subscribe

Your Environment

  "dependencies": {
    "ganache-core": "^2.3.3",
    "solc": "^0.5.3",
    "web3": "^1.0.0-beta.41"
  }
@benjamincburns
Copy link
Contributor

This is blocked by web3/web3.js#2266

@BlinkyStitt
Copy link

web3/web3.js#2266 was closed. Is this still blocked?

@fireblockdev
Copy link

fireblockdev commented Mar 19, 2019

With web3 1.0.0-beta.48, it works but with the new web 1.0.0-beta49, a simple sendTransaction crashes.

let web3 = new Web3(ganache.provider())
let ACCOUNTS = await web3.eth.getAccounts()
await web3.eth.sendTransaction({ from: ACCOUNTS[0], to: ACCOUNTS[1], value: 1 })

i have this error:

      at SafeSubscriber._next (node_modules/web3-core-method/dist/web3-core-method.cjs.js:1017:32)
      at SafeSubscriber.__tryOrUnsub (node_modules/rxjs/src/internal/Subscriber.ts:270:10)
      at SafeSubscriber.next (node_modules/rxjs/src/internal/Subscriber.ts:212:14)
      at Subscriber._next (node_modules/rxjs/src/internal/Subscriber.ts:141:22)
      at Subscriber.next (node_modules/rxjs/src/internal/Subscriber.ts:101:12)
      at TransactionObserver.emitNext (node_modules/web3-core-method/dist/web3-core-method.cjs.js:438:16)
      at _callee2$ (node_modules/web3-core-method/dist/web3-core-method.cjs.js:408:24)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:288:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
      at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at process.internalTickCallback (internal/process/next_tick.js:77:7)

@fireblockdev
Copy link

An issue related on web3.js web3/web3.js#2560

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants