You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constbusy=process.env.HFS_PARALLEL_UNC ? null : previous.get(uncHost)// by default we serialize requests on the same UNC host, to keep threadpool usage low
17
+
constret=pendingPromise<Stats>()
18
+
previous.set(uncHost,ret)// reserve the slot before starting the operation
19
+
consterr=awaitbusy?.then(()=>false,e=>e.message==='timeout'&&e)// only timeout error is shared with pending requests
20
+
if(err){
21
+
if(previous.get(uncHost)===ret)// but we don't want to block forever, only involve those that were already waiting
22
+
previous.delete(uncHost)
23
+
ret.reject(err)
24
+
returnret
25
+
}
26
+
while(working.size>=poolSize-1)// always leave one slot free for local operations
27
+
awaitPromise.race(working.values()).catch(()=>{})// we are assuming UV_THREADPOOL_SIZE > 1, otherwise race() will deadlock
// since nodejs' UV_THREADPOOL_SIZE is 4 by default, avoid using multiple slots for the same UNC host. This doesn't solve the problem but at least mitigates it.
0 commit comments