File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -168,8 +168,6 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV
168
168
} else {
169
169
throw new BadResponseError ( `Unsupported Content-Type: ${ contentType } ` )
170
170
}
171
- } catch ( err ) {
172
- log . error ( 'getProviders errored:' , err )
173
171
} finally {
174
172
signal . clear ( )
175
173
onFinish . resolve ( )
Original file line number Diff line number Diff line change @@ -82,6 +82,40 @@ describe('libp2p content-routing', () => {
82
82
} ) ) )
83
83
} )
84
84
85
+ it ( 'should respect abort signal when finding providers' , async ( ) => {
86
+ const routing = getContentRouting ( client )
87
+
88
+ if ( routing == null ) {
89
+ throw new Error ( 'ContentRouting not found' )
90
+ }
91
+
92
+ const providers = [ {
93
+ ID : ( await generateKeyPair ( 'Ed25519' ) ) . publicKey . toString ( ) ,
94
+ Addrs : [ '/ip4/43.43.43.43/tcp/1234' ]
95
+ } ]
96
+
97
+ const cid = CID . parse ( 'QmawceGscqN4o8Y8Fv26UUmB454kn2bnkXV5tEQYc4jBd6' )
98
+
99
+ // load providers for the router to fetch
100
+ await fetch ( `${ process . env . ECHO_SERVER } /add-providers/${ cid . toString ( ) } ` , {
101
+ method : 'POST' ,
102
+ body : providers . map ( prov => JSON . stringify ( prov ) ) . join ( '\n' )
103
+ } )
104
+
105
+ let findProvidersFinished = false
106
+ let error : any = new Error ( 'temporary error that should be replaced' )
107
+ try {
108
+ const controller = new AbortController ( )
109
+ controller . abort ( )
110
+ await all ( routing . findProviders ( cid , { signal : controller . signal } ) )
111
+ findProvidersFinished = true
112
+ } catch ( err : any ) {
113
+ error = err
114
+ }
115
+ expect ( findProvidersFinished ) . to . be . false ( )
116
+ expect ( error ) . to . have . property ( 'message' ) . that . includes ( 'abort' , error . message )
117
+ } )
118
+
85
119
it ( 'should provide without error' , async ( ) => {
86
120
const routing = getContentRouting ( client )
87
121
You can’t perform that action at this time.
0 commit comments