Skip to content

Commit

Permalink
fix: #1922
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Mar 17, 2024
1 parent bd08183 commit a4782bb
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-lamps-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Fixed `eth_unsubscribe` not being called for watch action teardown.
2 changes: 1 addition & 1 deletion src/actions/public/watchBlockNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export function watchBlockNumber<
onError?.(err as Error)
}
})()
return unsubscribe
return () => unsubscribe()
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/actions/public/watchBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export function watchBlocks<
onError?.(err as Error)
}
})()
return unsubscribe
return () => unsubscribe()
}

return enablePolling ? pollBlocks() : subscribeBlocks()
Expand Down
2 changes: 1 addition & 1 deletion src/actions/public/watchContractEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export function watchContractEvent<
onError?.(err as Error)
}
})()
return unsubscribe
return () => unsubscribe()
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/actions/public/watchEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export function watchEvent<
onError?.(err as Error)
}
})()
return unsubscribe
return () => unsubscribe()
}

return enablePolling ? pollEvent() : subscribeEvent()
Expand Down
2 changes: 1 addition & 1 deletion src/actions/public/watchPendingTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function watchPendingTransactions<
onError?.(err as Error)
}
})()
return unsubscribe
return () => unsubscribe()
}

return enablePolling
Expand Down

0 comments on commit a4782bb

Please sign in to comment.