Skip to content

Commit

Permalink
wip(cloud-function): split decodeJSON into text and json components
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Jul 30, 2024
1 parent 9ae1f55 commit 16d1dce
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cloud-function/src/handlers/render-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ export async function renderHTMLForContext(
if (!contextRes.ok) {
throw new Error(contextRes.statusText);
}
req.startServerTiming("decodeJSON");
context = await contextRes.json();
req.endServerTiming("decodeJSON");
req.startServerTiming("parseText");
const text = await contextRes.text();
req.endServerTiming("parseText");
req.startServerTiming("parseJSON");
context = JSON.parse(text);
req.endServerTiming("parseJSON");
res.statusCode = 200;
} catch {
context = { url: req.url, pageNotFound: true };
Expand Down

0 comments on commit 16d1dce

Please sign in to comment.