@@ -284,7 +284,7 @@ test('server/doh#cors - default', async function() {
284284 } ) ;
285285 const { headers } = await get ( `http://localhost:${ port } ` ) ;
286286 assert . equal ( headers [ 'access-control-allow-origin' ] , '*' ) ;
287- server . server . close ( ) ;
287+ server . close ( ) ;
288288} ) ;
289289
290290test ( 'server/doh#cors - no cors' , async function ( ) {
@@ -297,7 +297,7 @@ test('server/doh#cors - no cors', async function() {
297297 } ) ;
298298 const { headers } = await get ( `http://localhost:${ port } ` ) ;
299299 assert . equal ( headers [ 'access-control-allow-origin' ] , undefined ) ;
300- server . server . close ( ) ;
300+ server . close ( ) ;
301301} ) ;
302302
303303test ( 'server/doh#cors - cors origin' , async function ( ) {
@@ -311,7 +311,7 @@ test('server/doh#cors - cors origin', async function() {
311311 const { headers } = await get ( `http://localhost:${ port } ` ) ;
312312 assert . equal ( headers [ 'access-control-allow-origin' ] , 'some.domain' ) ;
313313 assert . equal ( headers . vary , 'Origin' ) ;
314- server . server . close ( ) ;
314+ server . close ( ) ;
315315} ) ;
316316
317317test ( 'server/doh#cors - cors function' , async function ( ) {
@@ -335,7 +335,7 @@ test('server/doh#cors - cors function', async function() {
335335 headers = ( await get ( `http://localhost:${ port } ` , { headers : { origin : 'b.domain' } } ) ) . headers ;
336336 assert . equal ( headers [ 'access-control-allow-origin' ] , 'false' ) ;
337337 assert . equal ( headers . vary , 'Origin' ) ;
338- server . server . close ( ) ;
338+ server . close ( ) ;
339339} ) ;
340340
341341// test('server/all#simple-request', async() => {
@@ -459,9 +459,13 @@ function get(url, options) {
459459}
460460
461461test ( 'client/doh' , async ( ) => {
462- const res = await DOHClient ( {
463- dns : 'https://1.0.0.1/dns-query' ,
464- } ) ( 'cdnjs.com' , 'NS' ) ;
462+ const timeout = new Promise ( ( _ , reject ) =>
463+ setTimeout ( ( ) => reject ( new Error ( 'DOH client timed out after 10s' ) ) , 10000 ) . unref ( )
464+ ) ;
465+ const res = await Promise . race ( [
466+ DOHClient ( { dns : 'https://1.0.0.1/dns-query' } ) ( 'cdnjs.com' , 'NS' ) ,
467+ timeout ,
468+ ] ) ;
465469
466470 // console.log(res);
467471 assert . equal ( res . answers . length , 2 ) ;
0 commit comments