Skip to content

Commit

Permalink
fix: withTimeout error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Jun 4, 2024
1 parent 3a5ea04 commit 7aad10e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/nasty-buses-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Added optional chaining to error handling in `withTimeout`.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion src/utils/promise/withTimeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function withTimeout<TData>(
}
resolve(await fn({ signal: controller?.signal || null }))
} catch (err) {
if ((err as Error).name === 'AbortError') reject(errorInstance)
if ((err as Error)?.name === 'AbortError') reject(errorInstance)
reject(err)
} finally {
clearTimeout(timeoutId)
Expand Down

0 comments on commit 7aad10e

Please sign in to comment.