cloudflare / chrome-devtools-rs

Rust library for the Chrome Devtools Protocol
MIT License
62 stars 4 forks source link

"attempt to subtract with overflow" printing empty object #53

Open jyn514 opened 3 years ago

jyn514 commented 3 years ago

Steps to reproduce:

  1. cargo install wrangler --version 1.19.5
  2. cargo generate --git https://github.com/cloudflare/websocket-template --name websocket
  3. cd websocket
  4. Apply this diff:

    
    diff --git a/websocket/index.js b/websocket/index.js
    index 0221c8f..baafb4e 100644
    --- a/websocket/index.js
    +++ b/websocket/index.js
    @@ -26,6 +26,7 @@ async function handleSession(websocket) {
    
    const websocketHandler = async request => {
    const upgradeHeader = request.headers.get("Upgrade")
    +  console.log(request.headers);
    if (upgradeHeader !== "websocket") {
     return new Response("Expected websocket", { status: 400 })
    }
    diff --git a/websocket/template.js b/websocket/template.js
    index 9ed9b93..c34fb92 100644
    --- a/websocket/template.js
    +++ b/websocket/template.js
    @@ -57,7 +57,7 @@ const template = `
    }
    
    const url = new URL(window.location)
    -  url.protocol = "wss"
    +  url.protocol = "ws"
    url.pathname = "/ws"
    websocket(url)
5. Navigate to http://127.0.0.1:8787/.

`chrome_devtools_rs` will panic:

<details>

2: core::panicking::panic at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:50:5 3: ::fmt at /home/jnelson/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/chrome-devtools-rs-0.0.0-alpha.3/src/domain/runtime/type/remote_object/type/object/object_preview/mod.rs:89:38 4: ::to_string at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/string.rs:2382:9 5: chrome_devtools::domain::runtime::type::remote_object::RemoteObject::display_object at /home/jnelson/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/chrome-devtools-rs-0.0.0-alpha.3/src/domain/runtime/type/remote_object/mod.rs:54:13 6: ::fmt at /home/jnelson/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/chrome-devtools-rs-0.0.0-alpha.3/src/domain/runtime/type/remote_object/mod.rs:102:29 7: <&T as core::fmt::Display>::fmt at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/fmt/mod.rs:2031:62 8: core::fmt::write at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/fmt/mod.rs:1110:17 9: core::fmt::Formatter::write_fmt at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/fmt/mod.rs:1556:9 10: ::fmt at /home/jnelson/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/chrome-devtools-rs-0.0.0-alpha.3/src/domain/runtime/event/console_api_called.rs:22:13 11: <&T as core::fmt::Display>::fmt at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/fmt/mod.rs:2031:62 12: core::fmt::write at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/fmt/mod.rs:1110:17 13: core::fmt::Formatter::write_fmt at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/fmt/mod.rs:1556:9 14: ::fmt at /home/jnelson/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/chrome-devtools-rs-0.0.0-alpha.3/src/domain/runtime/event/mod.rs:39:47 15: ::to_string at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/alloc/src/string.rs:2382:9 16: wrangler::commands::dev::socket::print_ws_messages::{{closure}} at /home/jnelson/src/wrangler/src/commands/dev/socket.rs:400:44 17: <core::future::from_generator::GenFuture as core::future::future::Future>::poll at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/future/mod.rs:80:19 18: <tokio::future::maybe_done::MaybeDone as core::future::future::Future>::poll at /home/jnelson/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/future/maybe_done.rs:68:48 19: wrangler::commands::dev::socket::listen::{{closure}}::{{closure}} at /home/jnelson/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/macros/try_join.rs:132:20 20: <tokio::future::poll_fn::PollFn as core::future::future::Future>::poll at /home/jnelson/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.13.0/src/future/poll_fn.rs:38:9 21: wrangler::commands::dev::socket::listen::{{closure}} at /home/jnelson/src/wrangler/src/commands/dev/socket.rs:132:16



</details>
jyn514 commented 3 years ago

https://github.com/cloudflare/chrome-devtools-rs/blob/d8fdf820d5337df1586fa0ff89b2bf420172522f/src/domain/runtime/type/remote_object/type/object/object_preview/mod.rs#L89