Skip to content

fix bindings/wasm wal file creation by implementing generate_random_number #1556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025

Conversation

OwenDelahoy
Copy link
Contributor

In binding/wasm generate_random_number's implementation depends on an external function Math_random which does not exist

A related error can be observed when viewing limbo-opfs-test.html without an existing database. (Note: it will execute successfully if the wal file already exists, so you may wish view the html in a private/incognito session to ensure an existing file from a previous run is not used)
Screenshot 2025-05-22 at 22 48 52

This error occurs upon wal file creation as it uses generate_random_number for salt_1 and slat_2 in the header
https://github.com/tursodatabase/limbo/blob/main/core/storage/wal.rs#L764-L773)

This PR uses the same implementation as other platforms

core/io/unix.rs
https://github.com/tursodatabase/limbo/blob/main/core/io/unix.rs#L259-L263

core/io/windows.rs
https://github.com/tursodatabase/limbo/blob/main/core/io/windows.rs#L40-L44

The library getrandom supports wasm and uses Crypto.getRandomValues for the implementation in wasm.

@jussisaurio jussisaurio merged commit 2ea7321 into tursodatabase:main May 23, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants