@@ -133,24 +133,25 @@ const useEOADetection = (
133133 return
134134 }
135135
136- const abortController = new AbortController ( )
137- const timeoutId = setTimeout ( ( ) => {
138- abortController . abort ( )
139- } , 2500 )
136+ const timeoutMs = 2500
137+ const timeoutError = new Error ( 'EOA_DETECTION_TIMEOUT' )
138+ let timeoutId : ReturnType < typeof setTimeout > | undefined
140139
141140 const startTime = performance . now ( )
142141
143142 try {
144143 const eoaResult = await Promise . race ( [
145144 wallet . isEOA ( chainId ! ) ,
146145 new Promise < never > ( ( _ , reject ) => {
147- abortController . signal . addEventListener ( 'abort' , ( ) => {
148- reject ( new Error ( 'EOA_DETECTION_TIMEOUT' ) )
149- } )
146+ timeoutId = setTimeout ( ( ) => {
147+ reject ( timeoutError )
148+ } , timeoutMs )
150149 } )
151150 ] )
152151
153- clearTimeout ( timeoutId )
152+ if ( timeoutId ) {
153+ clearTimeout ( timeoutId )
154+ }
154155 const { isEOA, isEIP7702Delegated } = eoaResult
155156 const explicitDepositValue = ! isEOA || isEIP7702Delegated
156157
@@ -160,9 +161,11 @@ const useEOADetection = (
160161 : current
161162 )
162163 } catch ( eoaError : any ) {
163- clearTimeout ( timeoutId )
164+ if ( timeoutId ) {
165+ clearTimeout ( timeoutId )
166+ }
164167 const duration = performance . now ( ) - startTime
165- const isTimeout = eoaError ?. message === 'EOA_DETECTION_TIMEOUT'
168+ const isTimeout = eoaError === timeoutError
166169
167170 if ( isTimeout ) {
168171 console . error ( '[EOA Detection] timeout' , {
0 commit comments