Skip to content

Commit

Permalink
chore: handling EADDRNOTAVAIL errors on top of ECONNREFUSED (#1967)
Browse files Browse the repository at this point in the history
  • Loading branch information
arboleya authored Mar 28, 2024
1 parent 4a44910 commit fb941a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-clocks-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fuels": patch
---

chore: handling `EADDRNOTAVAIL` errors on top of `ECONNREFUSED`
3 changes: 1 addition & 2 deletions packages/fuels/src/cli/commands/deploy/createWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export async function createWallet(providerUrl: string, privateKey?: string) {
return Wallet.fromPrivateKey(pvtKey, provider);
} catch (e) {
const error = e as Error & { cause?: { code: string } };

if (error.cause?.code === 'ECONNREFUSED') {
if (/EADDRNOTAVAIL|ECONNREFUSED/.test(error.cause?.code ?? '')) {
throw new FuelError(
FuelError.CODES.CONNECTION_REFUSED,
`Couldn't connect to the node at "${providerUrl}". Check that you've got a node running at the config's providerUrl or set autoStartFuelCore to true.`
Expand Down

0 comments on commit fb941a9

Please sign in to comment.