Skip to content

Uncaught TypeError: FinalizationRegistry: cleanup must be callable #577

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

Closed
grzegorz-jakubiak opened this issue Feb 13, 2025 · 2 comments
Closed

Comments

@grzegorz-jakubiak
Copy link

Issue

I cannot make app work with locally build ruby.wasm. I built the wasm binary by issuing: bundle exec rbwasm build -o ruby.wasm

This is my project.

Gemfile:

# frozen_string_literal: true

source "https://rubygems.org"

# Gemfile
gem 'ruby_wasm'
gem 'victor', '~> 0.5.0'

Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    ruby_wasm (2.7.1)
    ruby_wasm (2.7.1-aarch64-linux)
    ruby_wasm (2.7.1-aarch64-linux-musl)
    ruby_wasm (2.7.1-arm64-darwin)
    ruby_wasm (2.7.1-x86_64-darwin)
    ruby_wasm (2.7.1-x86_64-linux)
    ruby_wasm (2.7.1-x86_64-linux-musl)
    victor (0.5.0)

PLATFORMS
  aarch64-linux
  aarch64-linux-musl
  arm64-darwin
  ruby
  x86_64-darwin
  x86_64-linux
  x86_64-linux-musl

DEPENDENCIES
  ruby_wasm
  victor (~> 0.5.0)

BUNDLED WITH
   2.6.2

index.html:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Ruby WASM</title>
  </head>
  <body></body>
  <script type="module" src="index.js"></script>
</html>

index.js:

import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.7.1/dist/browser/+esm";
const response = await fetch("./ruby.wasm");
const module = await WebAssembly.compileStreaming(response);
const { vm } = await DefaultRubyVM(module);

vm.eval(`
  require "js"

  JS.global[:document].write "TEST"
`);

Result

What I get in the JS console is: Uncaught TypeError: FinalizationRegistry: cleanup must be callable.

When I try it with the cdn binary as documented in the cheat sheet every thing works without any issues.

What I want

What I want to achieve in the end is to execute a simple script:

# app.rb
require 'victor'

svg = Victor::SVG.new width: 100, height: 100

svg.build do
  rect x: 10, y: 10, width: 80, height: 80, fill: 'blue'
  circle cx: 50, cy: 50, r: 30, fill: 'green'
end

puts svg.render
@kateinoigakukun
Copy link
Member

Thank you for reporting. Could you try adding gem "js" to your Gemfile and rebuild the wasm again?

@grzegorz-jakubiak
Copy link
Author

Thanks a lot this fixed it :) I'm closing the issue :)

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

No branches or pull requests

2 participants