denoland / deno

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

Deno panic when using file:/// url with sass #26994

Open ploiu opened 14 hours ago

ploiu commented 14 hours ago

using a file:/// url with sass (e.g. from using import.meta.url) causes a panic.

panic log:

file:///home/ploiu/.cache/deno/npm/registry.npmjs.org/sass/1.81.0/sass.dart.js:1724769: Uncaught TypeError: Cannot read properties of undefined (reading 'length')

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 2.1.1
Args: ["/home/ploiu/.deno/bin/deno", "run", "-A", "./build.js"]

thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_v8-0.230.0/de.rs:582:47:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: serde_v8::de::from_v8
   5: deno_core::error::JsError::inner_from_v8_exception
   6: deno_core::error::exception_to_err_result
   7: deno_core::runtime::jsruntime::JsRuntime::poll_event_loop
   8: deno_core::runtime::jsruntime::JsRuntime::run_event_loop::{{closure}}
   9: deno_runtime::worker::MainWorker::run_event_loop::{{closure}}
  10: deno::worker::CliMainWorker::run::{{closure}}
  11: deno::tools::run::run_script::{{closure}}
  12: deno::spawn_subcommand::{{closure}}
  13: <deno_unsync::tokio::task::MaskFutureAsSend<F> as core::future::future::Future>::poll
  14: tokio::runtime::task::raw::poll
  15: deno::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

it throws an error using node as well (and when deno is using a package.json file oddly enough), but node/deno don't crash in that scenario.

reproducible example:

build.js

import * as sass from 'npm:sass'

const root = import.meta.url.replace('build.js', '')
const sassUrl = root + 'styles.scss'
// const sassUrl = './styles.scss' // this line works
sass.compile(sassUrl)

styles.scss

body {color: red;}

Please let me know if you need any more information!

uncomfyhalomacro commented 3 hours ago

Seems this line needs to be handled https://github.com/denoland/deno_core/blob/8980c84728f61d452fcbc95ec9730dc857c1e220/serde_v8/de.rs#L582 rather than unwrapping.