Skip to content

Commit

Permalink
fix(analyze): Disable cache during base64 decode (#838)
Browse files Browse the repository at this point in the history
Closes #836 

We are using `fetch` to base64 decode our Analyze Wasm files in certain runtimes. However, when this is used in the Next.js App Router, it fails because the URL is larger than 2mb. We don't actually need these to go through the `fetch` cache since it isn't making a network call, so we just disable it everywhere.
  • Loading branch information
blaine-arcjet authored May 29, 2024
1 parent e6321af commit 72fb961
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions analyze/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ const wasmBase64 = "data:application/wasm;base64,${wasm.toString("base64")}";
*/
// TODO: Switch back to top-level await when our platforms all support it
export async function wasm() {
// This uses fetch to decode the wasm data url
const wasmDecode = await fetch(wasmBase64);
// This uses fetch to decode the wasm data url, but disabling cache so files
// larger than 2mb don't fail to parse in the Next.js App Router
const wasmDecode = await fetch(wasmBase64, { cache: "no-store" });
const buf = await wasmDecode.arrayBuffer();
// And then we return it as a WebAssembly.Module
return WebAssembly.compile(buf);
Expand Down

0 comments on commit 72fb961

Please sign in to comment.