File tree Expand file tree Collapse file tree 2 files changed +20
-12
lines changed
src/account-abstraction/actions/bundler Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " viem " : patch
3+ ---
4+
5+ Fixed a bug where the timeout in ` waitForUserOperationReceipt ` was not properly cleared after the receipt was returned.
Original file line number Diff line number Diff line change @@ -92,14 +92,26 @@ export function waitForUserOperationReceipt(
9292 unobserve ( )
9393 }
9494
95+ const timeoutId = timeout ? setTimeout (
96+ ( ) =>
97+ done ( ( ) =>
98+ emit . reject (
99+ new WaitForUserOperationReceiptTimeoutError ( { hash } ) ,
100+ ) ,
101+ ) ,
102+ timeout ,
103+ ) : undefined
104+
95105 const unpoll = poll (
96106 async ( ) => {
97- if ( retryCount && count >= retryCount )
107+ if ( retryCount && count >= retryCount ) {
108+ clearTimeout ( timeoutId )
98109 done ( ( ) =>
99110 emit . reject (
100111 new WaitForUserOperationReceiptTimeoutError ( { hash } ) ,
101112 ) ,
102113 )
114+ }
103115
104116 try {
105117 const receipt = await getAction (
@@ -112,6 +124,8 @@ export function waitForUserOperationReceipt(
112124 const error = err as GetUserOperationReceiptErrorType
113125 if ( error . name !== 'UserOperationReceiptNotFoundError' )
114126 done ( ( ) => emit . reject ( error ) )
127+ } finally {
128+ clearTimeout ( timeoutId )
115129 }
116130
117131 count ++
@@ -122,17 +136,6 @@ export function waitForUserOperationReceipt(
122136 } ,
123137 )
124138
125- if ( timeout )
126- setTimeout (
127- ( ) =>
128- done ( ( ) =>
129- emit . reject (
130- new WaitForUserOperationReceiptTimeoutError ( { hash } ) ,
131- ) ,
132- ) ,
133- timeout ,
134- )
135-
136139 return unpoll
137140 } )
138141 } )
You can’t perform that action at this time.
0 commit comments