Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
Invalid function signature when loading Rust-generated webassembly binary from Python

The full code is here:

https://github.com/dmerejkowsky/chuck-norris-webassembly-plugins

Here's what's wrong

There's a get_fact method written in Rust and exported with wasm_bindgen:

#[wasm_bindgen]
pub fn get_fact() -> String {
    "Chuck Norris can slam a revolving door".to_string()
}

When I build the wasm file with wasm-pack --target nodejs I can call the get_fact just fine from Javascript:

const assert = require('node:assert/strict');
const ck = require('../pkg/chuck_norris.js');

const actual = ck.get_fact();
assert.ok(actual.includes("Chuck Norris"));

But when trying to write the same test in Python:

from wasmer import engine, Store, Module, Instance
from wasmer_compiler_cranelift import Compiler

rust_wasm = Path / "to" / "chucknorris_bg.wasm"

store = Store(engine.Universal(Compiler))
module = Module(store, rust_wasm.read_bytes())
instance = Instance(module)
get_fact = instance.exports.get_fact
actual = get_fact()
assert "Chuck Norris" in actual

I get :

RuntimeError: Parameters of type [] did not match signature [I32] -> []

Any clues as to why NodeJs and Python disagree on the signature of the get_fact() function ?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Answering myself: you cannot use webassembly with strings this way. More info on this blog post: https://medium.com/wasm/strings-in-webassembly-wasm-57a05c1ea333

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda