thepassle / eslint-plugin-barrel-files

MIT License
118 stars 10 forks source link

Runtime error `thread '<unnamed>' panicked at src/lib.rs:191:10:` #13

Open andymac4182 opened 3 months ago

andymac4182 commented 3 months ago

After adding the plugin and turning on all the rules to warn I got the below error.

thread '<unnamed>' panicked at src/lib.rs:191:10:
called `Result::unwrap()` on an `Err` value: NotFound("csstype")
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: eslint_barrel_file_utils::__napi__count_module_graph_size_rs::{{closure}}::{{closure}}
   4: eslint_barrel_file_utils::__napi__count_module_graph_size_rs
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
thepassle commented 3 months ago

Are you importing css files? Can you try adding css to extensions? https://github.com/thepassle/eslint-plugin-barrel-files/blob/main/docs/rules/avoid-importing-barrel-files.md#configuration

andymac4182 commented 2 months ago

We use images and CSS. Do I need to add all resolved extensions?

Here is my config

        "barrel-files/avoid-importing-barrel-files": [
            'error',
            {
                "extensions": [".js", ".ts", ".tsx", ".json", ".node", ".css"],
            }
        ]

I am still getting the same error after adding extensions.

Here is the full backtrace

thread '<unnamed>' panicked at src/lib.rs:191:10:
called `Result::unwrap()` on an `Err` value: NotFound("csstype")
stack backtrace:
   0:        0x121976568 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1f3776e0b5c7517d
   1:        0x1218d57d0 - core::fmt::write::heedef092c8c0962e
   2:        0x1219797ec - std::sys_common::backtrace::print::h417292deb95532ed
   3:        0x12197ac50 - std::panicking::rust_panic_with_hook::h5db4d2345b297bed
   4:        0x121979a00 - std::panicking::begin_panic_handler::{{closure}}::h3fd558f09a0d5492
   5:        0x121979968 - std::sys_common::backtrace::__rust_end_short_backtrace::hfc76eebe1ce501b2
   6:        0x12197995c - _rust_begin_unwind
   7:        0x12197bb38 - core::panicking::panic_fmt::hc2b459a5bd3dce66
   8:        0x12197bd9c - core::result::unwrap_failed::h88d7eb352f20b747
   9:        0x1218de220 - eslint_barrel_file_utils::__napi__count_module_graph_size_rs::{{closure}}::{{closure}}::hc5ca02913dc57434
  10:        0x1218dadb0 - eslint_barrel_file_utils::__napi__count_module_graph_size_rs::heefd60acb42952a8
fatal runtime error: failed to initiate panic, error 5

I just found I have a library that is just for types. https://www.npmjs.com/package/csstype

I made the config

        "barrel-files/avoid-importing-barrel-files": [
            'error',
            {
                "mainFields": ["module", "main", "browser", "types"],
            }
        ]

This is the new error I am getting.

thread '<unnamed>' panicked at src/lib.rs:166:80:
called `Result::unwrap()` on an `Err` value: Error { kind: InvalidData, message: "stream did not contain valid UTF-8" }
stack backtrace:
   0:        0x1111d6568 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1f3776e0b5c7517d
   1:        0x1111357d0 - core::fmt::write::heedef092c8c0962e
   2:        0x1111d97ec - std::sys_common::backtrace::print::h417292deb95532ed
   3:        0x1111dac50 - std::panicking::rust_panic_with_hook::h5db4d2345b297bed
   4:        0x1111d9a00 - std::panicking::begin_panic_handler::{{closure}}::h3fd558f09a0d5492
   5:        0x1111d9968 - std::sys_common::backtrace::__rust_end_short_backtrace::hfc76eebe1ce501b2
   6:        0x1111d995c - _rust_begin_unwind
   7:        0x1111dbb38 - core::panicking::panic_fmt::hc2b459a5bd3dce66
   8:        0x1111dbd9c - core::result::unwrap_failed::h88d7eb352f20b747
   9:        0x11113e0fc - eslint_barrel_file_utils::__napi__count_module_graph_size_rs::{{closure}}::{{closure}}::hc5ca02913dc57434
  10:        0x11113adb0 - eslint_barrel_file_utils::__napi__count_module_graph_size_rs::heefd60acb42952a8
fatal runtime error: failed to initiate panic, error 5
onethread commented 1 month ago

I'm getting something similar but with a different package:

thread '<unnamed>' panicked at src/lib.rs:191:10:
called `Result::unwrap()` on an `Err` value: NotFound("next/image")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
error Command failed with signal "SIGABRT".
ThulinaWickramasinghe commented 1 month ago

I'm getting an error like this from a next js project running on pages directory.

$ eslint --ignore-path .gitignore "src/**/*.+(ts|js|tsx)"
thread '<unnamed>' panicked at src/lib.rs:166:80:
called `Result::unwrap()` on an `Err` value: Error { kind: InvalidData, message: "stream did not contain valid UTF-8" }
stack backtrace:
   0:        0x11bf26568 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1f3776e0b5c7517d
   1:        0x11be857d0 - core::fmt::write::heedef092c8c0962e
   2:        0x11bf297ec - std::sys_common::backtrace::print::h417292deb95532ed
   3:        0x11bf2ac50 - std::panicking::rust_panic_with_hook::h5db4d2345b297bed
   4:        0x11bf29a00 - std::panicking::begin_panic_handler::{{closure}}::h3fd558f09a0d5492
   5:        0x11bf29968 - std::sys_common::backtrace::__rust_end_short_backtrace::hfc76eebe1ce501b2
   6:        0x11bf2995c - _rust_begin_unwind
   7:        0x11bf2bb38 - core::panicking::panic_fmt::hc2b459a5bd3dce66
   8:        0x11bf2bd9c - core::result::unwrap_failed::h88d7eb352f20b747
   9:        0x11be8e0fc - eslint_barrel_file_utils::__napi__count_module_graph_size_rs::{{closure}}::{{closure}}::hc5ca02913dc57434
  10:        0x11be8adb0 - eslint_barrel_file_utils::__napi__count_module_graph_size_rs::heefd60acb42952a8
fatal runtime error: failed to initiate panic, error 5
error Command failed with signal "SIGABRT".

When I try to figure the part of the code causing this error I found that it was caused by a custom npm package we're creating. And also we're getting a minified version of this package.