File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -1218,9 +1218,16 @@ class AleoNetworkClient {
1218
1218
1219
1219
if ( ! res . ok ) {
1220
1220
const text = await res . text ( ) ;
1221
- console . error ( "Non-OK response:" , res . status , text ) ;
1222
- clearInterval ( interval ) ;
1223
- return reject ( new Error ( `HTTP ${ res . status } : ${ text } ` ) ) ;
1221
+
1222
+ // Break early if the response indicates an invalid format
1223
+ if ( res . status >= 400 && res . status < 500 && text . includes ( "Invalid URL" ) ) {
1224
+ clearInterval ( interval ) ;
1225
+ return reject ( new Error ( `Malformed transaction ID: ${ text } ` ) ) ;
1226
+ }
1227
+
1228
+ // Log and continue polling for 404s or 5XX errors in case a tx doesn't exist yet
1229
+ console . warn ( "Non-OK response (retrying):" , res . status , text ) ;
1230
+ return ;
1224
1231
}
1225
1232
1226
1233
const data = await res . json ( ) ;
Original file line number Diff line number Diff line change @@ -211,12 +211,16 @@ describe('NodeConnection', () => {
211
211
expect ( status ) . to . equal ( "rejected" ) ;
212
212
} ) ;
213
213
214
- it ( 'should throw for an invalid tx ID' , async ( ) => {
215
- const connection = new AleoNetworkClient ( "https://api.explorer.provable.com/" ) ;
216
- await expectThrows ( ( ) =>
217
- connection . waitForTransactionConfirmation ( "at1dl9lze8wscct0dee8x9tjnfmpj12345678jcnp5f0ywjn5552yrsperzl9" )
218
- ) ;
219
- } ) ;
214
+ it ( 'should throw for a malformed tx ID' , async ( ) => {
215
+ const connection = new AleoNetworkClient ( "https://api.explorer.provable.com/" ) ;
216
+ try {
217
+ await connection . waitForTransactionConfirmation ( "at1dl9lze8wscct0dee8x9tjnfmpj12345678jcnp5f0ywjn5552yrsperzl9" ) ;
218
+ throw new Error ( "Expected waitForTransactionConfirmation to throw" ) ;
219
+ } catch ( err : any ) {
220
+ expect ( err . message ) . to . include ( "Malformed transaction ID" ) ;
221
+ expect ( err . message ) . to . include ( "Invalid URL" ) ;
222
+ }
223
+ } ) ;
220
224
} ) ;
221
225
222
226
describe ( 'findUnspentRecords' , ( ) => {
You can’t perform that action at this time.
0 commit comments