Skip to content

rust view panic can make reducer fail #3794

@xDovos

Description

@xDovos

it looks like that views can stop reducers from working if they error out.

#[table(name = test_table_datatypes, public)]
pub struct TestTableDatatypes {
    #[primary_key]
    #[auto_inc]
    pub t_u64: u64,
    #[index(btree)]
    pub t_u32: u32,
    // shortened for clarity
}

#[reducer]
pub fn clear_integration_tests(ctx: &ReducerContext){
    for row in ctx.db.test_table_datatypes().iter(){
        ctx.db.test_table_datatypes().delete(row);
    }
}

#[view(name = test_first_type_row, public)]
pub fn view_test_first_type_row(ctx: &ViewContext) -> Vec<TestTableDatatypes>{
    vec![ctx.db.test_table_datatypes().t_u32().filter(0..u32::MAX).next().unwrap()]
}

i know i shouldn't use unwrap like that and have it as

#[view(name = test_first_type_row, public)]
pub fn view_test_first_type_row(ctx: &ViewContext) -> Vec<TestTableDatatypes>{
    if let Some(row) = ctx.db.test_table_datatypes().t_u32().filter(0..u32::MAX).next(){
        vec![row]
    } else{
        vec![]
    }
}

but i wanted to know what happens when views error.

log errror

2025-11-30T14:39:40.725175Z PANIC: test_first_type_row src\main_types\integration_tests.rs:159: called `Option::unwrap()` on a `None` value
    in core::ops::function::Fn::call::hd2f658f7d0e1fd39
    in std::panicking::rust_panic_with_hook::he3dc6abfb01fb415
    in std::panicking::begin_panic_handler::{{closure}}::h8f2339f35afafb93
    in std::sys::backtrace::__rust_end_short_backtrace::h4aa478b171e13037
    in __rustc[de2ca18b4c54d5b8]::rust_begin_unwind
    in core::panicking::panic_fmt::h808dbde205a89691
    in core::panicking::panic::hd2efa669b7ab826e
    in core::option::unwrap_failed::h314697a0a1a32358
    in <Func as spacetimedb::rt::View<(),Elem>>::invoke::h9ee815c87d661ca5
    in spacetimedb::rt::invoke_view::h8a69c95d34f7731a
    in spacetime_module::main_types::integration_tests::view_test_first_type_row::invoke::h2271714ae5c944ad
    in __call_view__
2025-11-30T14:39:45.698837Z PANIC: test_first_type_row src\main_types\integration_tests.rs:159: called `Option::unwrap()` on a `None` value
    in core::ops::function::Fn::call::hd2f658f7d0e1fd39
    in std::panicking::rust_panic_with_hook::he3dc6abfb01fb415
    in std::panicking::begin_panic_handler::{{closure}}::h8f2339f35afafb93
    in std::sys::backtrace::__rust_end_short_backtrace::h4aa478b171e13037
    in __rustc[de2ca18b4c54d5b8]::rust_begin_unwind
    in core::panicking::panic_fmt::h808dbde205a89691
    in core::panicking::panic::hd2efa669b7ab826e
    in core::option::unwrap_failed::h314697a0a1a32358
    in <Func as spacetimedb::rt::View<(),Elem>>::invoke::h9ee815c87d661ca5
    in spacetimedb::rt::invoke_view::h8a69c95d34f7731a
    in spacetime_module::main_types::integration_tests::view_test_first_type_row::invoke::h2271714ae5c944ad
    in __call_view__

server cmd error

←[2m2025-11-30T14:39:40.725436Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m27←[0m←[2m:←[0m view "test_first_type_row" runtime error: error while executing at wasm backtrace:
    0: 0x31dbe - spacetime_module.wasm!__rustc[de2ca18b4c54d5b8]::__rust_abort
    1: 0x2fc0a - spacetime_module.wasm!__rustc[de2ca18b4c54d5b8]::__rust_start_panic
    2: 0x32a51 - spacetime_module.wasm!__rustc[de2ca18b4c54d5b8]::rust_panic
    3: 0x32a41 - spacetime_module.wasm!std::panicking::rust_panic_with_hook::he3dc6abfb01fb415
    4: 0x31f2c - spacetime_module.wasm!std::panicking::begin_panic_handler::{{closure}}::h8f2339f35afafb93
    5: 0x31e66 - spacetime_module.wasm!std::sys::backtrace::__rust_end_short_backtrace::h4aa478b171e13037
    6: 0x325dd - spacetime_module.wasm!__rustc[de2ca18b4c54d5b8]::rust_begin_unwind
    7: 0x33734 - spacetime_module.wasm!core::panicking::panic_fmt::h808dbde205a89691
    8: 0x336fd - spacetime_module.wasm!core::panicking::panic::hd2efa669b7ab826e
    9: 0x34dab - spacetime_module.wasm!core::option::unwrap_failed::h314697a0a1a32358
   10: 0x11602 - spacetime_module.wasm!<Func as spacetimedb::rt::View<(),Elem>>::invoke::h9ee815c87d661ca5
   11: 0x10cd - spacetime_module.wasm!spacetimedb::rt::invoke_view::h8a69c95d34f7731a
   12: 0x1261b - spacetime_module.wasm!spacetime_module::main_types::integration_tests::view_test_first_type_row::invoke::h2271714ae5c944ad
   13: 0x26e6a - spacetime_module.wasm!__call_view__
←[2m2025-11-30T14:39:40.725803Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #14: __rustc[de2ca18b4c54d5b8]::__rust_abort
←[2m2025-11-30T14:39:40.728062Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #13: __rustc[de2ca18b4c54d5b8]::__rust_start_panic
←[2m2025-11-30T14:39:40.728487Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #12: __rustc[de2ca18b4c54d5b8]::rust_panic
←[2m2025-11-30T14:39:40.729174Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #11: std::panicking::rust_panic_with_hook::he3dc6abfb01fb415
←[2m2025-11-30T14:39:40.729513Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #10: std::panicking::begin_panic_handler::{{closure}}::h8f2339f35afafb93
←[2m2025-11-30T14:39:40.729855Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #9: std::sys::backtrace::__rust_end_short_backtrace::h4aa478b171e13037
←[2m2025-11-30T14:39:40.730069Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #8: __rustc[de2ca18b4c54d5b8]::rust_begin_unwind
←[2m2025-11-30T14:39:40.730287Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #7: core::panicking::panic_fmt::h808dbde205a89691
←[2m2025-11-30T14:39:40.730498Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #6: core::panicking::panic::hd2efa669b7ab826e
←[2m2025-11-30T14:39:40.730760Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #5: core::option::unwrap_failed::h314697a0a1a32358
←[2m2025-11-30T14:39:40.730983Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #4: <Func as spacetimedb::rt::View<(),Elem>>::invoke::h9ee815c87d661ca5
←[2m2025-11-30T14:39:40.731205Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #3: spacetimedb::rt::invoke_view::h8a69c95d34f7731a
←[2m2025-11-30T14:39:40.731417Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #2: spacetime_module::main_types::integration_tests::view_test_first_type_row::invoke::h2271714ae5c944ad
←[2m2025-11-30T14:39:40.731630Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #1: __call_view__
←[2m2025-11-30T14:39:45.698947Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m27←[0m←[2m:←[0m view "test_first_type_row" runtime error: error while executing at wasm backtrace:
    0: 0x31dbe - spacetime_module.wasm!__rustc[de2ca18b4c54d5b8]::__rust_abort
    1: 0x2fc0a - spacetime_module.wasm!__rustc[de2ca18b4c54d5b8]::__rust_start_panic
    2: 0x32a51 - spacetime_module.wasm!__rustc[de2ca18b4c54d5b8]::rust_panic
    3: 0x32a41 - spacetime_module.wasm!std::panicking::rust_panic_with_hook::he3dc6abfb01fb415
    4: 0x31f2c - spacetime_module.wasm!std::panicking::begin_panic_handler::{{closure}}::h8f2339f35afafb93
    5: 0x31e66 - spacetime_module.wasm!std::sys::backtrace::__rust_end_short_backtrace::h4aa478b171e13037
    6: 0x325dd - spacetime_module.wasm!__rustc[de2ca18b4c54d5b8]::rust_begin_unwind
    7: 0x33734 - spacetime_module.wasm!core::panicking::panic_fmt::h808dbde205a89691
    8: 0x336fd - spacetime_module.wasm!core::panicking::panic::hd2efa669b7ab826e
    9: 0x34dab - spacetime_module.wasm!core::option::unwrap_failed::h314697a0a1a32358
   10: 0x11602 - spacetime_module.wasm!<Func as spacetimedb::rt::View<(),Elem>>::invoke::h9ee815c87d661ca5
   11: 0x10cd - spacetime_module.wasm!spacetimedb::rt::invoke_view::h8a69c95d34f7731a
   12: 0x1261b - spacetime_module.wasm!spacetime_module::main_types::integration_tests::view_test_first_type_row::invoke::h2271714ae5c944ad
   13: 0x26e6a - spacetime_module.wasm!__call_view__
←[2m2025-11-30T14:39:45.699340Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #14: __rustc[de2ca18b4c54d5b8]::__rust_abort
←[2m2025-11-30T14:39:45.701429Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #13: __rustc[de2ca18b4c54d5b8]::__rust_start_panic
←[2m2025-11-30T14:39:45.701772Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #12: __rustc[de2ca18b4c54d5b8]::rust_panic
←[2m2025-11-30T14:39:45.702097Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #11: std::panicking::rust_panic_with_hook::he3dc6abfb01fb415
←[2m2025-11-30T14:39:45.702389Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #10: std::panicking::begin_panic_handler::{{closure}}::h8f2339f35afafb93
←[2m2025-11-30T14:39:45.702657Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #9: std::sys::backtrace::__rust_end_short_backtrace::h4aa478b171e13037
←[2m2025-11-30T14:39:45.702911Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #8: __rustc[de2ca18b4c54d5b8]::rust_begin_unwind
←[2m2025-11-30T14:39:45.703142Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #7: core::panicking::panic_fmt::h808dbde205a89691
←[2m2025-11-30T14:39:45.703409Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #6: core::panicking::panic::hd2efa669b7ab826e
←[2m2025-11-30T14:39:45.703646Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #5: core::option::unwrap_failed::h314697a0a1a32358
←[2m2025-11-30T14:39:45.703693Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #4: <Func as spacetimedb::rt::View<(),Elem>>::invoke::h9ee815c87d661ca5
←[2m2025-11-30T14:39:45.703947Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #3: spacetimedb::rt::invoke_view::h8a69c95d34f7731a
←[2m2025-11-30T14:39:45.704180Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #2: spacetime_module::main_types::integration_tests::view_test_first_type_row::invoke::h2271714ae5c944ad
←[2m2025-11-30T14:39:45.704418Z←[0m ←[32m INFO←[0m ←[2mcrates\core\src\host\wasmtime\wasmtime_module.rs←[0m←[2m:←[0m←[2m31←[0m←[2m:←[0m   Frame #1: __call_view__

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions