From b5edf0edd558d1ce06938311acf425fe392b9910 Mon Sep 17 00:00:00 2001 From: halfnelson Date: Mon, 4 Mar 2019 20:21:30 +1000 Subject: [PATCH] Fix export race condition (#585) * Await all items in the export queue before killing server --- src/api/export.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/api/export.ts b/src/api/export.ts index 793a102..ba6a9db 100644 --- a/src/api/export.ts +++ b/src/api/export.ts @@ -163,7 +163,6 @@ async function _export({ const cleaned = clean_html(body); const q = yootils.queue(8); - let promise; const base_match = //m.exec(cleaned); const base_href = base_match && get_href(base_match[1]); @@ -180,12 +179,12 @@ async function _export({ const url = resolve(base.href, href); if (url.protocol === protocol && url.host === host) { - promise = q.add(() => handle(url)); + q.add(() => handle(url)); } } } - await promise; + await q.close(); } } }