Skip to content

Commit

Permalink
feat: add 502, 503, 504 as non-deterministic errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Feb 19, 2023
1 parent 89ff839 commit 8ef068b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/nervous-phones-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Added `502`, `503` and `504` error codes as "non-deterministic" errors for `fallback` transport & retries.
24 changes: 24 additions & 0 deletions src/utils/buildRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,30 @@ describe('isDeterministicError', () => {
).toBe(false)
})

test('HttpRequestError (502)', () => {
expect(
isDeterministicError(
new HttpRequestError({ body: {}, details: '', status: 502, url: '' }),
),
).toBe(false)
})

test('HttpRequestError (503)', () => {
expect(
isDeterministicError(
new HttpRequestError({ body: {}, details: '', status: 503, url: '' }),
),
).toBe(false)
})

test('HttpRequestError (504)', () => {
expect(
isDeterministicError(
new HttpRequestError({ body: {}, details: '', status: 504, url: '' }),
),
).toBe(false)
})

test('HttpRequestError (429)', () => {
expect(
isDeterministicError(
Expand Down
5 changes: 4 additions & 1 deletion src/utils/buildRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export const isDeterministicError = (error: Error) => {
error.status !== 408 &&
error.status !== 413 &&
error.status !== 429 &&
error.status !== 500
error.status !== 500 &&
error.status !== 502 &&
error.status !== 503 &&
error.status !== 504
)
return true
}
Expand Down

2 comments on commit 8ef068b

@vercel
Copy link

@vercel vercel bot commented on 8ef068b Feb 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viem-playground – ./playgrounds/browser

viem-playground-wagmi-dev.vercel.app
viem-playground.vercel.app
viem-playground-git-main-wagmi-dev.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 8ef068b Feb 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viem-site – ./site

viem-site-wagmi-dev.vercel.app
viem-site.vercel.app
viem-site-git-main-wagmi-dev.vercel.app

Please sign in to comment.