Skip to content

Panic on wasm32-unknown-unknown without js feature#297

Merged
BurntSushi merged 7 commits intoBurntSushi:masterfrom
jprochazk:js-feature-panic
Apr 18, 2025
Merged

Panic on wasm32-unknown-unknown without js feature#297
BurntSushi merged 7 commits intoBurntSushi:masterfrom
jprochazk:js-feature-panic

Conversation

@jprochazk
Copy link
Contributor

@jprochazk jprochazk commented Mar 12, 2025

Suggested here: #296 (comment)

I quickly put together a hello-world trunk project, and called jiff::Zoned::new() in it, without the js feature enabled.

The resulting panic
panicked at /home/dev/jiff/src/now.rs:30:9:
getting the current time in wasm32-unknown-unknown is not possible, enable jiff's `js` feature if you are targeting a browser environment

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_8a6f238a6ece86ea@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8.js:246:21
trunk_hello_world-a7f87d88668d9124.wasm.__wbg_new_8a6f238a6ece86ea externref shim@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[2337]:0xace89
trunk_hello_world-a7f87d88668d9124.wasm.console_error_panic_hook::Error::new::hd7ee4fcdd982d38a@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[1604]:0xa261a
trunk_hello_world-a7f87d88668d9124.wasm.console_error_panic_hook::hook_impl::h8821c57ba8c469cf@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[384]:0x6b573
trunk_hello_world-a7f87d88668d9124.wasm.console_error_panic_hook::hook::ha79e4afb6a587815@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[2127]:0xaae76
trunk_hello_world-a7f87d88668d9124.wasm.core::ops::function::Fn::call::hf0dffdd551dbc510@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[1836]:0xa6c59
trunk_hello_world-a7f87d88668d9124.wasm.std::panicking::rust_panic_with_hook::he163a328f096b027@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[861]:0x8ac32
trunk_hello_world-a7f87d88668d9124.wasm.std::panicking::begin_panic_handler::{{closure}}::h9b4576c502f796bb@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[1039]:0x92541
trunk_hello_world-a7f87d88668d9124.wasm.std::sys::backtrace::__rust_end_short_backtrace::h9dcf082627c76851@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[2385]:0xad164
trunk_hello_world-a7f87d88668d9124.wasm.rust_begin_unwind@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[2218]:0xac02e
trunk_hello_world-a7f87d88668d9124.wasm.core::panicking::panic_fmt::hf09e831ea9f1651a@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[2219]:0xac05a
trunk_hello_world-a7f87d88668d9124.wasm.jiff::now::sys::system_time::h898a41a65599799d@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[1683]:0xa405a
trunk_hello_world-a7f87d88668d9124.wasm.jiff::zoned::Zoned::now::hc9862d1e6d3623ca@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[1068]:0x9364a
trunk_hello_world-a7f87d88668d9124.wasm.trunk_hello_world::main::h4c62d89c82d63174@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[232]:0x57da9
trunk_hello_world-a7f87d88668d9124.wasm.core::ops::function::FnOnce::call_once::h891fbf1087931a90@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[2038]:0xa9c5a
trunk_hello_world-a7f87d88668d9124.wasm.std::sys::backtrace::__rust_begin_short_backtrace::h8f5930db5e671fb7@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[2036]:0xa9bec
trunk_hello_world-a7f87d88668d9124.wasm.std::rt::lang_start::{{closure}}::hcdc519022ca63bd4@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[1292]:0x9aa9a
trunk_hello_world-a7f87d88668d9124.wasm.std::rt::lang_start_internal::hca8730f87f82319d@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[944]:0x8e7cf
trunk_hello_world-a7f87d88668d9124.wasm.std::rt::lang_start::he22437a03640fe91@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[1158]:0x9683b
trunk_hello_world-a7f87d88668d9124.wasm.main@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[2302]:0xacb32
trunk_hello_world-a7f87d88668d9124.wasm.@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[2362]:0xad048
trunk_hello_world-a7f87d88668d9124.wasm.@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8_bg.wasm:wasm-function[2391]:0xad19c
__wbg_finalize_init@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8.js:315:10
__wbg_init@http://127.0.0.1:8080/trunk-hello-world-39605882ec2e39d8.js:369:12


trunk-hello-world-39605882ec2e39d8.js:230:21

@jprochazk jprochazk force-pushed the js-feature-panic branch 3 times, most recently from 80ecf78 to 105db4f Compare March 12, 2025 20:06
Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thank you! Just a few nits.

@jprochazk
Copy link
Contributor Author

@BurntSushi Hi, could you please take another look at this?

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

jprochazk and others added 6 commits April 18, 2025 08:07
@BurntSushi
Copy link
Owner

I pushed a tweak to the language here.

@BurntSushi BurntSushi merged commit d08fcb3 into BurntSushi:master Apr 18, 2025
34 checks passed
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 this pull request may close these issues.

provide better panic message for Zoned::now on wasm32-unknown-unknown when js feature is not enabled

3 participants