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

FETCH FAILED: socket error when creating accounts #1783

Closed
Tracked by #1763
suyash67 opened this issue Aug 24, 2023 · 5 comments · Fixed by #2015
Closed
Tracked by #1763

FETCH FAILED: socket error when creating accounts #1783

suyash67 opened this issue Aug 24, 2023 · 5 comments · Fixed by #2015
Assignees
Labels
T-bug Type: Bug. Something is broken.

Comments

@suyash67
Copy link
Contributor

In the sandbox guide, we add new stuff to index.ts (eg. for retrieving logs, we add the code from the image-1) and run yarn start. But I also have previous actions in the index.ts (eg. creating accounts). After I run yarn start I see the logs as in image-2. We see the error: foundation:retry ERROR TypeError: fetch failed which suggests that the sandbox failed to create accounts in the first attempt and succeeded in the second one (probably because of some connectivity issue). The reason for this seems unknown but we should ensure that external developers interpret this correctly and don't bother about this error.

image-1:
image

image-2:
image (4)

@suyash67 suyash67 added the T-fix Type: fix this. Not quite a bug. label Aug 24, 2023
@github-project-automation github-project-automation bot moved this to Todo in A3 Aug 24, 2023
@iAmMichaelConnor iAmMichaelConnor added this to the 📢 Initial Public Sandbox Release milestone Aug 25, 2023
@iAmMichaelConnor iAmMichaelConnor changed the title Sandbox improvement: socket error when creating accounts FETCH FAILED: socket error when creating accounts Sep 1, 2023
@iAmMichaelConnor iAmMichaelConnor added T-bug Type: Bug. Something is broken. and removed T-fix Type: fix this. Not quite a bug. labels Sep 1, 2023
@iAmMichaelConnor
Copy link
Contributor

Note to whomever picks this up - I've encountered this fetch failed error for most commands that I try in the Sandbox. It eventually succeeds, but it's an unfortunate first impression :)

@spypsy spypsy self-assigned this Sep 1, 2023
@spypsy
Copy link
Member

spypsy commented Sep 1, 2023

Tried multiple CLI commands & calling from Aztec.js, but can't reproduce this anymore. Are ppl still seeing this??
I'm using the latest released versions for Sandbox & CLI

@iAmMichaelConnor
Copy link
Contributor

iAmMichaelConnor commented Sep 2, 2023

I just updated to the latest sandbox (docker image b7843965884c...) & cli (version 0.1.0-alpha49), and I'm still seeing it.

In particular, I'm consistently seeing it when running the deploy function. Running with DEBUG=*, I get the error every time it reaches addContracts. The error appears once, then on a retry it succeeds:

 aztec:wasm initial mem: 30 pages, 1.875mb. max mem: 8192 pages, 512mb +0ms
  json-rpc:json_rpc_client JsonRpcClient.constructor proxy addContracts <- [
  [
    {
      abi: [Object],
      completeAddress: [CompleteAddress],
      portalContract: [EthAddress]
    }
  ]
] +8s
  json-rpc:json_rpc_client JsonRpcClient.request addContracts <- [
  [
    {
      abi: [Object],
      completeAddress: [CompleteAddress],
      portalContract: [EthAddress]
    }
  ]
] +1ms
  json-rpc:json_rpc_client JsonRpcClient.fetch http://localhost:8085 addContracts -> {
  jsonrpc: '2.0',
  id: 2,
  method: 'addContracts',
  params: [ [ [Object] ] ]
} +1ms
  aztec:foundation:retry JsonRpcClient request failed. Will retry in 1s... +0ms
  aztec:foundation:retry TypeError: fetch failed
  aztec:foundation:retry     at Object.fetch (node:internal/deps/undici/undici:11576:11)
  aztec:foundation:retry     at async defaultFetch (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/foundation/dest/json-rpc/client/json_rpc_client.js:28:16)
  aztec:foundation:retry     at async retry (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/foundation/dest/retry/index.js:46:20)
  aztec:foundation:retry     at async file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/foundation/dest/json-rpc/client/json_rpc_client.js:63:16
  aztec:foundation:retry     at async request (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/foundation/dest/json-rpc/client/json_rpc_client.js:81:21)
  aztec:foundation:retry     at async DeployMethod.create (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/aztec.js/dest/contract_deployer/deploy_method.js:56:9)
  aztec:foundation:retry     at async DeployMethod.simulate (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/aztec.js/dest/contract/base_contract_interaction.js:16:46)
  aztec:foundation:retry     at async file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/aztec.js/dest/contract/base_contract_interaction.js:31:36
  aztec:foundation:retry     at async SentTx.getTxHash (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/aztec.js/dest/contract/sent_tx.js:25:16)
  aztec:foundation:retry     at async DeploySentTx.getTxHash (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/aztec.js/dest/contract/sent_tx.js:25:16) +0ms
  json-rpc:json_rpc_client JsonRpcClient.fetch http://localhost:8085 addContracts -> {
  jsonrpc: '2.0',
  id: 2,
  method: 'addContracts',
  params: [ [ [Object] ] ]
} +1s
  json-rpc:json_rpc_client JsonRpcClient.result addContracts -> { jsonrpc: '2.0', id: 2 } +39ms

Also, for a transfer, I get the error when it tries getExtendedContractData:

  json-rpc:json_rpc_client JsonRpcClient.request getExtendedContractData <- [
  AztecAddress {
    buffer: <Buffer 1b 13 56 b8 45 04 9e 93 d0 49 71 dd 52 3f 4b ca b1 6a f2 c5 e9 59 cc aa 19 cf e4 8a 0f 78 e5 63>
  }
] +1ms
  json-rpc:json_rpc_client JsonRpcClient.fetch http://localhost:8085 getExtendedContractData -> {
  jsonrpc: '2.0',
  id: 1,
  method: 'getExtendedContractData',
  params: [
    {
      type: 'AztecAddress',
      data: '0x1b1356b845049e93d04971dd523f4bcab16af2c5e959ccaa19cfe48a0f78e563'
    }
  ]
} +1ms
  aztec:foundation:retry JsonRpcClient request failed. Will retry in 1s... +0ms
  aztec:foundation:retry TypeError: fetch failed
  aztec:foundation:retry     at Object.fetch (node:internal/deps/undici/undici:11576:11)
  aztec:foundation:retry     at async defaultFetch (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/foundation/dest/json-rpc/client/json_rpc_client.js:28:16)
  aztec:foundation:retry     at async retry (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/foundation/dest/retry/index.js:46:20)
  aztec:foundation:retry     at async file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/foundation/dest/json-rpc/client/json_rpc_client.js:63:16
  aztec:foundation:retry     at async request (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/foundation/dest/json-rpc/client/json_rpc_client.js:81:21)
  aztec:foundation:retry     at async Contract.at (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/@aztec/aztec.js/dest/contract/contract.js:18:38)
  aztec:foundation:retry     at async Command.<anonymous> (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/dest/index.js:299:26)
  aztec:foundation:retry     at async Command.parseAsync (/Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/node_modules/commander/lib/command.js:935:5)
  aztec:foundation:retry     at async main (file:///Users/mike/.nvm/versions/node/v20.3.1/lib/node_modules/@aztec/cli/dest/bin/index.js:10:5) +0ms
  json-rpc:json_rpc_client JsonRpcClient.fetch http://localhost:8085 getExtendedContractData -> {
  jsonrpc: '2.0',
  id: 1,
  method: 'getExtendedContractData',
  params: [
    {
      type: 'AztecAddress',
      data: '0x1b1356b845049e93d04971dd523f4bcab16af2c5e959ccaa19cfe48a0f78e563'
    }
  ]
} +1s
  json-rpc:json_rpc_client JsonRpcClient.result getExtendedContractData -> {
  jsonrpc: '2.0',
  id: 1,
  result: {
    type: 'ExtendedContractData',
    data: '1b1356b845049e93d04971dd523f4bcab16af2c5e959ccaa19cfe48a0f78e56300000000000000000000000000000000000000000000000009c19a2aae51e8191dbbbadf3148d5e3b392cd645d21dc3dfe4813a8e7e2075500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
  }
} +10ms

(Edit: I'm using port 8085, because 8080 is already in use for mainframe access).

spypsy added a commit that referenced this issue Sep 5, 2023
Fixes #1783 
Add `failSilently` option to `retry` function. 
This means that nothing will be printed until we run out of retries, at
which point the error will be thrown.
@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Sep 5, 2023
@iAmMichaelConnor
Copy link
Contributor

@spypsy why was it failing on the first try, sometimes? What would cause this?

@spypsy
Copy link
Member

spypsy commented Sep 5, 2023

I spent a lot of time trying to reproduce it reliably and even when I managed to do that, after inserting a bunch of debugging code and trying to figure out why, it stopped failing again.
So I'm patching it for now to improve developer experience and can create a ticket to investigate further on the cause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: Bug. Something is broken.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants