Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not detect network error when using litNodeClient.connect() #17

Open
1 task done
spacesailor24 opened this issue Apr 22, 2024 · 11 comments
Open
1 task done

Comments

@spacesailor24
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

SDK version

This issue was originally reported in Discord

User used default installed version of SDK: ^5.0.0 and also tried 4.2.1

Lit Network

habanero and cayenne

Description of the bug/issue

Hi team, I am following the user guide https://developer.litprotocol.com/v3/sdk/wallets/quick-start. When I do below

const litNodeClient = new LitJsSdk.LitNodeClientNodeJs({
  alertWhenUnauthorized: false,
  litNetwork: 'habanero',
});
await litNodeClient.connect();

I get following error.

 ⨯ Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)
    at Logger.makeError (webpack-internal:///(rsc)/./node_modules/@ethersproject/logger/lib.esm/index.js:231:23)
    at Logger.throwError (webpack-internal:///(rsc)/./node_modules/@ethersproject/logger/lib.esm/index.js:240:20)
    at JsonRpcProvider.eval (webpack-internal:///(rsc)/./node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js:458:27)
    at Generator.throw (<anonymous>)
    at rejected (webpack-internal:///(rsc)/./node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js:22:65)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:538:9)
    at process.processTimers (node:internal/timers:512:7) {
  reason: 'could not detect network',
  code: 'NETWORK_ERROR',
  event: 'noNetwork'

Somehow the library sees noNetwork, any ideas what might be wrong ?

Other things I tried,

  • Downgraded to lit-node-client:4.2.1 but this this error
  • Tried litNetwork: 'cayenne' with v5 but got below.
 ⨯ errConstructorFunc {
  message: 'Error getting current epoch number: Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)',
  errorCode: 'UnknownError',
  errorKind: 'Unknown',
  status: undefined,
  details: undefined,
  requestI

I cannot seem to find a way-out, any ideas ?

Severity of the bug

N/A

Steps To Reproduce

N/A

Link to code

I created a simple repo to try to reproduce, but wasn't able to

Anything else?

No response

@kavukcutolga
Copy link

Hi, I was trying with a simple next app, I pushed the code here https://github.com/kavukcutolga/lit-client-error-next.

Try yarn install then yarn dev then hit http://localhost:3000/api/hello. You should see the error in the output

@joshLong145
Copy link

@kavukcutolga
From the looks of the first error

 ⨯ Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)
    at Logger.makeError (webpack-internal:///(rsc)/./node_modules/@ethersproject/logger/lib.esm/index.js:231:23)
    at Logger.throwError (webpack-internal:///(rsc)/./node_modules/@ethersproject/logger/lib.esm/index.js:240:20)
    at JsonRpcProvider.eval (webpack-internal:///(rsc)/./node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js:458:27)
    at Generator.throw (<anonymous>)
    at rejected (webpack-internal:///(rsc)/./node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js:22:65)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:538:9)
    at process.processTimers (node:internal/timers:512:7) {
  reason: 'could not detect network',
  code: 'NETWORK_ERROR',
  event: 'noNetwork'

I think this is an issue with the environment in which this is running presumably Vercel's serverless api runtime. The error seems to be coming from ethers and saying it cannot find a suitable network provider. I am curious if you use this in the client context with nextjs client side rendering enabled for the component if it will connect.

@kavukcutolga
Copy link

It's actually getting this issue in my laptop, not in vercel. I presume same should happen with you too.
Maybe there are some interceptors breaking the client , I can give a try with client side rendering to isolate the problem.

@kavukcutolga
Copy link

kavukcutolga commented Apr 24, 2024

It seems this a known problem with ethers and next 14, there is a workaround available but needs to be fixed in lit SDK it seems. ethers-io/ethers.js#4469 (comment), does it look the same to you as well?

They are also saying this is fixed with ethers V6, is lit SDK using v5 or V6.

@joshLong145
Copy link

At this time we are still using ethers v5 does it fit your use case to downgrade to NextJS 13

@joshLong145
Copy link

Digging into this issue thread it seems like we might be able to expose some configuration options for the RpcProvider which will allow compatibility with NextJS 14
ethers-io/ethers.js#4469 (comment)

@kavukcutolga
Copy link

That would be great, the problem with downgrading is I will have to upgrade it again. So it's a pain

@kavukcutolga
Copy link

kavukcutolga commented Apr 26, 2024

Hi any thoughts on exposing the configuration via sdk for v5 ?

@spacesailor24
Copy link
Author

Hey @kavukcutolga! We have a patch for this in progress, and we’ll link the PR for this when it’s ready which should be in about 2 weeks - thank you for your patience!

@kavukcutolga
Copy link

Hello, any updates on this?

@joshLong145
Copy link

@kavukcutolga
We will have a new build out soon with a fix for this included. will tag this thread when it is ready.

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

No branches or pull requests

3 participants