File tree Expand file tree Collapse file tree 4 files changed +14
-6
lines changed Expand file tree Collapse file tree 4 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,10 @@ class Backend {
3838 this . options = { ...getDefaults ( ) , ...( this . options || { } ) , ...options }
3939 this . allOptions = allOptions
4040 if ( this . services && this . options . reloadInterval ) {
41- setInterval ( ( ) => this . reload ( ) , this . options . reloadInterval )
41+ const timer = setInterval ( ( ) => this . reload ( ) , this . options . reloadInterval )
42+ if ( typeof timer === 'object' ) {
43+ timer . unref ( )
44+ }
4245 }
4346 }
4447
Original file line number Diff line number Diff line change 7777 "compile" : " npm run compile:esm && npm run compile:cjs" ,
7878 "browser" : " browserify --ignore cross-fetch --standalone i18nextHttpBackend cjs/index.js -o i18nextHttpBackend.js && uglifyjs i18nextHttpBackend.js --compress --mangle -o i18nextHttpBackend.min.js" ,
7979 "build" : " npm run compile && npm run browser" ,
80- "test:xmlhttpreq" : " mocha test -R spec --require test/fixtures/xmlHttpRequest.cjs --exit -- experimental-modules" ,
81- "test:fetch" : " mocha test -R spec --exit -- experimental-modules" ,
80+ "test:xmlhttpreq" : " mocha test -R spec --require test/fixtures/xmlHttpRequest.cjs --experimental-modules" ,
81+ "test:fetch" : " mocha test -R spec --experimental-modules" ,
8282 "test" : " npm run lint && npm run build && npm run test:fetch && npm run test:xmlhttpreq && npm run test:typescript" ,
8383 "test:typescript" : " tslint --project tsconfig.json && tsd" ,
8484 "test:deno" : " deno test --allow-net test/deno/*.js" ,
Original file line number Diff line number Diff line change @@ -6,6 +6,11 @@ const server = (done) => {
66 if ( js ) return done ( null , js )
77
88 js = jsonServer . create ( )
9+ js . use ( ( req , res , next ) => {
10+ // disable keep alive so the test server can close quickly.
11+ res . setHeader ( 'Connection' , 'close' )
12+ next ( )
13+ } )
914 js . use ( jsonServer . bodyParser )
1015
1116 js . get ( '/locales/en/testqs' , ( req , res ) => {
@@ -54,7 +59,7 @@ const server = (done) => {
5459 js . listen ( 5001 , ( ) => {
5560 console . log ( 'JSON Server is running' )
5661 done ( null , js )
57- } )
62+ } ) . unref ( )
5863}
5964
6065export default server
Original file line number Diff line number Diff line change @@ -41,8 +41,8 @@ describe(`http backend using ${hasXMLHttpRequest() ? 'XMLHttpRequest' : 'fetch'}
4141 errO = err
4242 dataO = data
4343 resolve ( true )
44- setTimeout ( ( ) => reject ( new Error ( 'timeout' ) ) , 1500 )
4544 } )
45+ setTimeout ( ( ) => reject ( new Error ( 'timeout' ) ) , 1500 ) . unref ( )
4646 } )
4747 // evaluate outside callback to get actuall error when something is wrong
4848 expect ( errO ) . to . be ( null )
@@ -72,8 +72,8 @@ describe(`http backend using ${hasXMLHttpRequest() ? 'XMLHttpRequest' : 'fetch'}
7272 errO = err
7373 dataO = data
7474 resolve ( true )
75- setTimeout ( ( ) => reject ( new Error ( 'timeout' ) ) , 1500 )
7675 } )
76+ setTimeout ( ( ) => reject ( new Error ( 'timeout' ) ) , 1500 ) . unref ( )
7777 } )
7878 // evaluate outside callback to get actuall error when something is wrong
7979 expect ( errO ) . to . be ( null )
You can’t perform that action at this time.
0 commit comments