From 45fb0ea4f4382a988e1c363044d4fb574b66c26f Mon Sep 17 00:00:00 2001 From: Erki Aas Date: Tue, 13 Dec 2022 16:59:29 +0200 Subject: [PATCH] Fix function usage, add workaround for a Bun bug --- index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 4d436a2..6b37840 100644 --- a/index.ts +++ b/index.ts @@ -45,10 +45,11 @@ const getScreenshots = async function (resp: object, path: string): Promise export default { port: 3000, async fetch(request: Request) { + await new Promise((r) => setTimeout(r, 1)); // https://github.com/oven-sh/bun/issues/1600 let reqUrl = await parseUrl(request.url) let req = await request.json(); - let promises = getScreenshots(req, reqUrl.path) - return Promise.all(promises).then((r) => { + + return Promise.all(await getScreenshots(req, reqUrl.path)).then((r) => { let resp = Object.assign({}, req) resp.screenshots = r return resp