@@ -207,28 +207,29 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
207207
208208 // TODO add a test for failure (at the sync level)
209209 const client = await this . client . acquire ( ) ;
210- const res = (
211- await client . client . get ( url , {
212- params,
213- // some altcoin may have outputs with values > MAX_SAFE_INTEGER
214- transformResponse : ( string ) =>
215- // eslint-disable-next-line @typescript-eslint/no-explicit-any
216- JSONBigNumber . parse ( string , ( key : string , value : any ) => {
217- if ( BigNumber . isBigNumber ( value ) ) {
218- if ( key === "value" ) {
219- return value . toString ( ) ;
210+ let res : { txs : TX [ ] } = { txs : [ ] } ;
211+ try {
212+ res = (
213+ await client . client . get ( url , {
214+ params,
215+ // some altcoin may have outputs with values > MAX_SAFE_INTEGER
216+ transformResponse : ( string ) =>
217+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
218+ JSONBigNumber . parse ( string , ( key : string , value : any ) => {
219+ if ( BigNumber . isBigNumber ( value ) ) {
220+ if ( key === "value" ) {
221+ return value . toString ( ) ;
222+ }
223+ return value . toNumber ( ) ;
220224 }
221-
222- return value . toNumber ( ) ;
223- }
224- return value ;
225- } ) ,
226- } )
227- ) . data as { txs : TX [ ] } ;
228- await this . client . release ( client ) ;
229-
225+ return value ;
226+ } ) ,
227+ } )
228+ ) . data ;
229+ } finally {
230+ await this . client . release ( client ) ;
231+ }
230232 this . emit ( "fetched-address-transaction" , { url, params, res } ) ;
231-
232233 return res ;
233234 }
234235
@@ -305,7 +306,6 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
305306 params . block_hash = lastTx . block . hash ;
306307 }
307308 }
308-
309309 const res = await this . fetchTxs ( address , params ) ;
310310
311311 const hydratedTxs : TX [ ] = [ ] ;
0 commit comments