From f9016d13ee34c6bbfaacfea6316fc511e1bdec94 Mon Sep 17 00:00:00 2001 From: keyan Date: Wed, 12 Jan 2022 19:35:17 -0600 Subject: [PATCH] only check capture if not page is not cached --- pages/api/capture/[[...path]].js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pages/api/capture/[[...path]].js b/pages/api/capture/[[...path]].js index a1aa01d2..126fad95 100644 --- a/pages/api/capture/[[...path]].js +++ b/pages/api/capture/[[...path]].js @@ -15,12 +15,6 @@ AWS.config.update({ }) export default async function handler (req, res) { - if (capturing) { - return res.writeHead(503, { - 'Retry-After' : 1 - }).end() - } - return new Promise(resolve => { const joinedPath = path.join(...(req.query.path || [])) const s3Path = s3PathPrefix + (joinedPath === '.' ? '_' : joinedPath) @@ -38,6 +32,12 @@ export default async function handler (req, res) { resolve() }).catch(() => { // we don't have it cached, so capture it and cache it + if (capturing) { + return res.writeHead(503, { + 'Retry-After' : 1 + }).end() + } + capturing = true const pass = new PassThrough() aws.upload({