Promise will never complete error for WASI worker

I'm writing a WASI worker using @cloudflare/workers-wasi and while it works locally using wrangler, I get a Promise will never complete. error when actually deploying to cloudflare workers. I am using Wrangler 3.4.0 and Rust 1.71.0. I am building the WASI image using cargo-wasi in release mode, so wasm-opt is enabled. worker.ts
import { WASI } from '@cloudflare/workers-wasi';
import demoWasm from '../../../target/wasm32-wasi/release/wasi_test.wasm';
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const stdout = new TransformStream();
const wasi = new WASI({
stdout: stdout.writable
});
const instance = new WebAssembly.Instance(demoWasm, {
wasi_snapshot_preview1: wasi.wasiImport
});
ctx.waitUntil(wasi.start(instance));
return new Response(stdout.readable);
}
};
import { WASI } from '@cloudflare/workers-wasi';
import demoWasm from '../../../target/wasm32-wasi/release/wasi_test.wasm';
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const stdout = new TransformStream();
const wasi = new WASI({
stdout: stdout.writable
});
const instance = new WebAssembly.Instance(demoWasm, {
wasi_snapshot_preview1: wasi.wasiImport
});
ctx.waitUntil(wasi.start(instance));
return new Response(stdout.readable);
}
};
main.rs
use image;

fn main() {
let image_bytes = include_bytes!("foster-lake.jpg");
let mut img = image::load_from_memory(image_bytes).expect("Failed to parse image");
let height = img.height();
println!("{height}");
}
use image;

fn main() {
let image_bytes = include_bytes!("foster-lake.jpg");
let mut img = image::load_from_memory(image_bytes).expect("Failed to parse image");
let height = img.height();
println!("{height}");
}
The code seems to fail specifically on image::load_from_memory(image_bytes). The include_bytes does work as the worker runtime correctly returns the image if I try to directly print out the bytes of the image to stdout. I don't expect to have hit any aborts or panics as the image is being loaded correctly and it decodes correctly locally. Are there known behavior differences between wrangler and the worker runtime for WASI?
1 Reply
Deepfried Chicken
I'm running into something similar now.... have you managed to discover the problem by any chance?
Want results from more Discord servers?
Add your server