near / near-workspaces-js

Write tests once, run them both on NEAR TestNet and a controlled NEAR Sandbox local environment
https://near.github.io/near-workspaces-js/
GNU General Public License v3.0
42 stars 22 forks source link

IPv6 issues, hiding problems #205

Open rafales opened 1 year ago

rafales commented 1 year ago

Ok, so. I tried to run tests - written in AVA. For some reason. I quickly figured out the code responsible:

image

It was hanging on the createSubAccount. Sadly after a long timeout all I got was this:

  Error (TypedError) {
    context: undefined,
    type: 'RetriesExceeded',
    message: 'Exceeded 10 attempts for http://localhost:1593.',
  }

  › Object.fetchJson (node_modules/near-api-js/lib/utils/web.js:55:15)
  › async node_modules/near-api-js/lib/providers/json-rpc-provider.js:312:34
  › async Object.exponentialBackoff [as default] (node_modules/near-api-js/lib/utils/exponential-backoff.js:7:24)
  › async JsonRpcProvider.sendJsonRpc (node_modules/near-api-js/lib/providers/json-rpc-provider.js:304:26)
  › async JsonRpcProvider.query (node_modules/near-api-js/lib/providers/json-rpc-provider.js:116:22)
  › async Account.findAccessKey (node_modules/near-api-js/lib/account.js:186:31)
  › async Account.signTransaction (node_modules/near-api-js/lib/account.js:91:31)

Adding NEAR_WORKSPACES_DEBUG=true didn't help either.

One of the issues is that the code handling backoffs is hiding the reason of the failure, making it hard to track the real issues.

In the end the issue here is:

error: FetchError: request to http://localhost:1592/ failed, reason: connect ECONNREFUSED ::1:1592

Meaning that even though near-sandbox listens on IPv4 the app attempts to connect at IPv6. Not sure what the right fix here is, probably near-sandbox should also listen on IPv6 or maybe the url shouldn't use localhost but the IP address instead.

> node -v
v19.6.0
roshaans commented 9 months ago

Was there a fix discovered for this?

roshaans commented 9 months ago

This helped me fix the problem: https://github.com/near/near-workspaces-js/issues/168#issuecomment-1481592599