Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bundles/wasm/src/wabt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export const wrun = (buffer: number[] | Uint8Array) => {
buffer = new Uint8Array(buffer);
}

const exps = new WebAssembly.Instance(new WebAssembly.Module(buffer)).exports;
const exps = new WebAssembly.Instance(new WebAssembly.Module(Buffer.from(buffer))).exports;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The use of Buffer.from() in code compiled for the browser may cause a ReferenceError because Buffer is not a standard browser global.
Severity: MEDIUM

πŸ” Detailed Analysis

The code at src/bundles/wasm/src/wabt.ts uses Buffer.from(buffer). This file is compiled for a browser environment where the Buffer global is not natively available. Unless the build process is configured to polyfill Buffer, this will likely cause a ReferenceError: Buffer is not defined at runtime when the wrun function is executed, preventing the WebAssembly module from being instantiated.

πŸ’‘ Suggested Fix

Remove the Buffer.from() call. The WebAssembly.Module constructor can accept a Uint8Array or ArrayBuffer directly, which buffer is likely to be. The line should be changed to const wasmModule = new WebAssembly.Module(buffer);.

πŸ€– Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/bundles/wasm/src/wabt.ts#L22

Potential issue: The code at `src/bundles/wasm/src/wabt.ts` uses `Buffer.from(buffer)`.
This file is compiled for a browser environment where the `Buffer` global is not
natively available. Unless the build process is configured to polyfill `Buffer`, this
will likely cause a `ReferenceError: Buffer is not defined` at runtime when the `wrun`
function is executed, preventing the WebAssembly module from being instantiated.

Did we get this right? πŸ‘ / πŸ‘Ž to inform future reviews.
Reference ID: 8512705

return objectToLinkedList(exps);
};
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17433,12 +17433,12 @@ __metadata:
linkType: hard

"typescript@npm:^5.8.2":
version: 5.8.3
resolution: "typescript@npm:5.8.3"
version: 5.9.3
resolution: "typescript@npm:5.9.3"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/5f8bb01196e542e64d44db3d16ee0e4063ce4f3e3966df6005f2588e86d91c03e1fb131c2581baf0fb65ee79669eea6e161cd448178986587e9f6844446dbb48
checksum: 10c0/6bd7552ce39f97e711db5aa048f6f9995b53f1c52f7d8667c1abdc1700c68a76a308f579cd309ce6b53646deb4e9a1be7c813a93baaf0a28ccd536a30270e1c5
languageName: node
linkType: hard

Expand Down Expand Up @@ -17473,12 +17473,12 @@ __metadata:
linkType: hard

"typescript@patch:typescript@npm%3A^5.8.2#optional!builtin<compat/typescript>":
version: 5.8.3
resolution: "typescript@patch:typescript@npm%3A5.8.3#optional!builtin<compat/typescript>::version=5.8.3&hash=5786d5"
version: 5.9.3
resolution: "typescript@patch:typescript@npm%3A5.9.3#optional!builtin<compat/typescript>::version=5.9.3&hash=5786d5"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/39117e346ff8ebd87ae1510b3a77d5d92dae5a89bde588c747d25da5c146603a99c8ee588c7ef80faaf123d89ed46f6dbd918d534d641083177d5fac38b8a1cb
checksum: 10c0/ad09fdf7a756814dce65bc60c1657b40d44451346858eea230e10f2e95a289d9183b6e32e5c11e95acc0ccc214b4f36289dcad4bf1886b0adb84d711d336a430
languageName: node
linkType: hard

Expand Down
Loading