Skip to content

fix: add runtime.getRandomData import for tinygo v0.37.0+#195

Open
pedramktb wants to merge 1 commit into
syumai:mainfrom
pedramktb:fix/tinygo-wasm-getRandomData
Open

fix: add runtime.getRandomData import for tinygo v0.37.0+#195
pedramktb wants to merge 1 commit into
syumai:mainfrom
pedramktb:fix/tinygo-wasm-getRandomData

Conversation

@pedramktb

@pedramktb pedramktb commented May 1, 2026

Copy link
Copy Markdown

TinyGo v0.37.0 updated the net submodule (tinygo-org/net) which introduced
a call to runtime.getRandomData in the compiled wasm binary. Without a
corresponding JS implementation in the gojs import object, instantiating
the module throws:

LinkError: WebAssembly.Instance(): Import # 17 "gojs" "runtime.getRandomData":
function import requires a callable

The addition is already present at the official go runtime package, though the same is missing on TinyGo.

Corresponding PR on TinyGo: tinygo-org/tinygo#5363.

Copilot AI review requested due to automatic review settings May 1, 2026 23:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds the missing gojs import implementation for runtime.getRandomData in the TinyGo WASM JS shim so TinyGo v0.37.0+ modules can instantiate without a LinkError when the updated tinygo-org/net triggers this runtime import.

Changes:

  • Implement gojs["runtime.getRandomData"] using crypto.getRandomValues(...) to fill a WASM-provided byte slice.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pedramktb pedramktb force-pushed the fix/tinygo-wasm-getRandomData branch from ab92c48 to 1b41bc2 Compare May 1, 2026 23:52
@pedramktb pedramktb requested a review from Copilot May 1, 2026 23:58
@pedramktb pedramktb force-pushed the fix/tinygo-wasm-getRandomData branch from 1b41bc2 to 18e67c9 Compare May 2, 2026 00:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@syumai

syumai commented May 4, 2026

Copy link
Copy Markdown
Owner

@pedramktb Thanks!
I just added wasm_exec_tinygo.js generator in #201.
Therefore, I'll regenerate it after the next version of TinyGo is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants