Skip to content
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

1.3.4 and 1.3.3 failing in Cloudflare Worker env for different reasons #689

Closed
kmusick opened this issue Jun 22, 2023 · 0 comments · Fixed by #690
Closed

1.3.4 and 1.3.3 failing in Cloudflare Worker env for different reasons #689

kmusick opened this issue Jun 22, 2023 · 0 comments · Fixed by #690

Comments

@kmusick
Copy link
Contributor

kmusick commented Jun 22, 2023

I'm really in over my head on this one but here is my understanding.

Due to changes mentioned in #687, 1.3.4 does not work correctly in wasm32-unknown-unknown:

panicked at 'time not implemented on this platform', library/std/src/sys/wasm/../unsupported/time.rs:31:9

However, 1.3.3 also fails on Cloudflare Workers:

LinkError: WebAssembly.Instance(): Import #9 module="./index_bg.js" function="__wbg_now_5eac63e226f04e45" error: function import requires a callable

With the changes made in PR #688, all wasm32-unknown-unknown tests work fine. A very similar issue is brought up in this issue. Applying the same fix keeps all tests happy and allows v7_now() to be used in Cloudflare Workers. Here is the fix:

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(js_namespace = Date)]
    fn now() -> f64;
}

let now = now();

becomes:

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(js_namespace = Date, catch)]
    fn now() -> Result<f64, JsValue>;
}

let now = now().unwrap_throw();

Not sure how to test for this and I don't really understand what is causing the issue. However, the updated code works and passes all tests.

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 a pull request may close this issue.

1 participant