denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.82k stars 5.39k forks source link

panicked at op_cache_storage_open when treating images with https://deno.land/x/imagemagick_deno #22144

Closed danielfroz closed 5 months ago

danielfroz commented 9 months ago

Hi,

I am facing panick errors while optimizing images using the "https://deno.land/x/imagemagick_deno@0.0.26/mod.ts" package.

I added debug log statements before and after any function where has some action and noticed that this happens while working with this package.

Here is the error from the backtrace:

Platform: linux x86_64
Version: 1.39.4
Args: ["./service"]

thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.245.0/gotham_state.rs:82:3:
required type deno_cache::CreateCache<deno_cache::sqlite::SqliteBackedCache> is not present in GothamState container
stack backtrace:
   0:     0x561517b1b85c - std::backtrace_rs::backtrace::libunwind::trace::ha637c64ce894333a
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x561517b1b85c - std::backtrace_rs::backtrace::trace_unsynchronized::h47f62dea28e0c88d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x561517b1b85c - std::sys_common::backtrace::_print_fmt::h9eef0abe20ede486
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x561517b1b85c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hed7f999df88cc644
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x561517b51120 - core::fmt::rt::Argument::fmt::h1539a9308b8d058d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
   5:     0x561517b51120 - core::fmt::write::h3a39390d8560d9c9
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
   6:     0x561517b1563f - std::io::Write::write_fmt::h5fc9997dfe05f882
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
   7:     0x561517b1b644 - std::sys_common::backtrace::_print::h894006fb5c6f3d45
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x561517b1b644 - std::sys_common::backtrace::print::h23a2d212c6fff936
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x561517b1d307 - std::panicking::default_hook::{{closure}}::h8a1d2ee00185001a
  10:     0x561517b1d06f - std::panicking::default_hook::h6038f2eba384e475
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
  11:     0x561517ff0654 - deno::setup_panic_hook::{{closure}}::h616c3ba1f2c73079
  12:     0x561517b1d988 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1f8f335eaa9cfaee
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
  13:     0x561517b1d988 - std::panicking::rust_panic_with_hook::h2b5517d590cab22e
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:783:13
  14:     0x561517b1d6de - std::panicking::begin_panic_handler::{{closure}}::h233112c06e0ef43e
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
  15:     0x561517b1bd26 - std::sys_common::backtrace::__rust_end_short_backtrace::h6e893f24d7ebbff8
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x561517b1d442 - rust_begin_unwind
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
  17:     0x561517b4e1a5 - core::panicking::panic_fmt::hbf0e066aabfa482c
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
  18:     0x5615186ca6d2 - deno_core::gotham_state::missing::hc2e3d64f377b660c
  19:     0x5615183f6db2 - deno_cache::get_cache::hcac8c40e5f035585
  20:     0x5615183f4cdf - deno_cache::op_cache_storage_open<CA>::call::{{closure}}::h019f4901e6f713ee
  21:     0x5615183f524e - deno_cache::op_cache_storage_open<CA>::v8_fn_ptr::h81a758c31a462406
  22:     0x56151792f95d - Builtins_CallApiCallbackGeneric

I am using denoland/deno:alpine-1.39.4 build at my cloud.

BTW tried to upgrade to the latest release (1.40.2)... but unfortunately Decorators implementation is breaking my code. I am using tsyringe (https://github.com/microsoft/tsyringe) in my code. So the upgrade does not work even adding "experimentalDecorators"; it compiles but at runtime it complains on "@singleton".

The error reported and also the error on release 1.40 does not happen on my computer (Mac m1). Downgraded deno to release 1.39.4 on my computer as well.

Please let me know how to fix this?

Foosballfan commented 8 months ago
import {
  ImageMagick,
  IMagickImage,
  initializeImageMagick,
  MagickFormat,
} from 'npm:@imagemagick/magick-wasm';

const wasmFile = import.meta.resolve('./magick.wasm');
const file = await fetch(wasmFile);
const wasm = await file.arrayBuffer();
await initializeImageMagick(wasm);

I was able to work around this issue by using npm:@imagemagick/magick-wasm and copying out the wasm file into my codebase. Now works when compiled.