Repository: deno
Issue: integration::websocketstream is flaky
Labels: flaky

https://github.com/denoland/deno/runs/8136335004?check_suite_focus=true

```
============================================================
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: macos x86_64
Version: 1.25.0
Args: ["/Users/runner/work/deno/deno/target/debug/deno", "test", "--unstable", "--allow-net", "--cert", "/Users/runner/work/deno/deno/cli/tests/testdata/tls/RootCA.pem", "/Users/runner/work/deno/deno/cli/tests/testdata/websocketstream_test.ts"]

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Bad resource ID', ext/websocket/lib.rs:486:52
stack backtrace:
   0:        0x106e84a84 - std::backtrace_rs::backtrace::libunwind::trace::hc513dadde6954c86
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x106e84a84 - std::backtrace_rs::backtrace::trace_unsynchronized::hef5b528e06275835
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x106e84a84 - std::sys_common::backtrace::_print_fmt::hd90f3854346e0ebc
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:66:5
   3:        0x106e84a84 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h85521558a183f368
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:45:22
   4:        0x106ea859b - core::fmt::write::h01631fae0d2b98bc
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:1197:17
   5:        0x106e7c3e8 - std::io::Write::write_fmt::h675dde99a2999169
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/io/mod.rs:1672:15
   6:        0x106e8692d - std::sys_common::backtrace::_print::h9f1d91ee7cd2be55
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:48:5
   7:        0x106e8692d - std::sys_common::backtrace::print::h4ad640f11cc29383
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:35:9
   8:        0x106e8692d - std::panicking::default_hook::***closure***::h5e5df492d229fd65
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:295:22
   9:        0x106e86684 - std::panicking::default_hook::h18647b59f1a84ee2
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:314:9
  10:        0x102377260 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h05cbf83d1cc79eee
  11:        0x101b05dce - deno::setup_panic_hook::***closure***::h31ec12c45ab71272
  12:        0x106e86f2b - std::panicking::rust_panic_with_hook::hd9ead35a68ccc55e
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:702:17
  13:        0x106e86da3 - std::panicking::begin_panic_handler::***closure***::h6fca91c5e1dc2f30
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:588:13
  14:        0x106e84f07 - std::sys_common::backtrace::__rust_end_short_backtrace::h4ff3025d9a0a0490
sync close with empty stream ...test integration::websocketstream ... FAILED
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:138:18
  15:        0x106e86a7a - rust_begin_unwind
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
  16:        0x106f4fc03 - core::panicking::panic_fmt::h3d9f795ee387ef8d
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
  17:        0x106f4fcf5 - core::result::unwrap_failed::haca1aa19e4c34aab
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/result.rs:1805:5
  18:        0x105b2bfd3 - core::result::Result<T,E>::unwrap::h6b5583dd0304fde7
  19:        0x104d4b0e6 - deno_websocket::op_ws_next_event::call::***closure***::h36b19745bcf94006
  20:        0x104d7dca5 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h0ec2b892b5d37287
  21:        0x104d4bcce - deno_websocket::op_ws_next_event::v8_func::***closure***::h9f1a04231300d894
  22:        0x104d7decb - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hbe9484e4a9b18feb
  23:        0x105a6581f - <core::pin::Pin<P> as core::future::future::Future>::poll::h07491e6959e04669
  24:        0x105b0f214 - <futures_util::future::maybe_done::MaybeDone<Fut> as core::future::future::Future>::poll::he891069999b88856
  25:        0x105a7039b - <deno_core::ops::OpCall<T> as core::future::future::Future>::poll::h3053182caedd8354
  26:        0x105a341c6 - <futures_util::stream::futures_unordered::FuturesUnordered<Fut> as futures_core::stream::Stream>::poll_next::h733825f8facecc89
  27:        0x105a3ade1 - futures_util::stream::stream::StreamExt::poll_next_unpin::h173882184a245dfd
  28:        0x105b079d3 - deno_core::runtime::JsRuntime::resolve_async_ops::h5dbbdf880a83464a
  29:        0x105aff7b8 - deno_core::runtime::JsRuntime::poll_event_loop::h119a72b7c10e4f10
  30:        0x105afefd9 - deno_core::runtime::JsRuntime::poll_value::h432e415932aba9ae
  31:        0x101a9bf51 - deno_core::runtime::JsRuntime::resolve_value::***closure***::***closure***::h6c1751142ed5c7d8
  32:        0x10238477e - <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll::h4012284f0033ba8d
  33:        0x101a9be3a - deno_core::runtime::JsRuntime::resolve_value::***closure***::h56f594192fcf7442
  34:        0x101bc1e84 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::he6f5b0d101274f00
  35:        0x101c74783 - deno::worker::CliMainWorker::run_test_specifier::***closure***::h68346444c4bba394
  36:        0x101bc29d4 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hee9f1f004ab55ffb
  37:        0x101ade500 - deno::tools::test::test_specifier::***closure***::h71217668b8b22b7b
  38:        0x101bb9fd4 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::ha51d83058f4ba7b2
  39:        0x10272c610 - <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::***closure***::***closure***::h641975d7b8cc9ef9
  40:        0x10244926b - tokio::coop::with_budget::***closure***::h4f3715dd847d217f
  41:        0x101a19e46 - std::thread::local::LocalKey<T>::try_with::h8b22f37fae0eec85
  42:        0x101a16ea8 - std::thread::local::LocalKey<T>::with::h36798a4267ec2804
  43:        0x10272c439 - <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::***closure***::heefef811cd9c5366
  44:        0x102453121 - tokio::macros::scoped_tls::ScopedKey<T>::set::h7a100cc3ec38be57
  45:        0x10270c855 - tokio::task::local::LocalSet::with::h38f3d3202a9233d5
  46:        0x10272b96d - <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::h5ea1cabeb9dc3226
  47:        0x10270dc92 - tokio::task::local::LocalSet::run_until::***closure***::hfd27de3cfe9972c5
  48:        0x101bbc844 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hb8c820934befd529
  49:        0x1027285aa - <core::pin::Pin<P> as core::future::future::Future>::poll::h87f7c74b06cce3a6
  50:        0x10271d95a - tokio::runtime::basic_scheduler::CoreGuard::block_on::***closure***::***closure***::***closure***::h787f081242675307
  51:        0x10244adcb - tokio::coop::with_budget::***closure***::hedd15cbe39423301
  52:        0x101a1a7e6 - std::thread::local::LocalKey<T>::try_with::h9ef9f4dcfe276a7a
  53:        0x101a17d88 - std::thread::local::LocalKey<T>::with::hdb21e4b23d53cdfc
  54:        0x10271d10f - tokio::runtime::basic_scheduler::CoreGuard::block_on::***closure***::***closure***::h4152ec9533df2d28
  55:        0x102712f6a - tokio::runtime::basic_scheduler::Context::enter::hea1981b50ca83058
  56:        0x10271a1c4 - tokio::runtime::basic_scheduler::CoreGuard::block_on::***closure***::h24fbc25f6c72bc05
  57:        0x10271966b - tokio::runtime::basic_scheduler::CoreGuard::enter::***closure***::h55a2accf680ad650
  58:        0x102453321 - tokio::macros::scoped_tls::ScopedKey<T>::set::h98070e2f0b2dcc56
  59:        0x10271938e - tokio::runtime::basic_scheduler::CoreGuard::enter::hf22f0868d09b2b35
  60:        0x1027198c8 - tokio::runtime::basic_scheduler::CoreGuard::block_on::h63f8f6881b4181b4
  61:        0x10270dea3 - tokio::runtime::basic_scheduler::BasicScheduler::block_on::h4656ea27e8e4fde3
  62:        0x1023741ac - tokio::runtime::Runtime::block_on::h9d26b639f928a278
  63:        0x10270cb55 - tokio::task::local::LocalSet::block_on::h57e9586277371b28
  64:        0x101bf4772 - deno_runtime::tokio_util::run_local::hac43559e5f1bab4a
  65:        0x101ae350f - deno::tools::test::test_specifiers::***closure***::***closure***::***closure***::h7c04a508733c1092
  66:        0x101eca746 - <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll::h89d05150677c16a7
  67:        0x101f7ff0c - tokio::runtime::task::core::CoreStage<T>::poll::***closure***::h35983d865ea99244
  68:        0x101e962f9 - tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut::h655a312e1ba8058e
  69:        0x101f7f691 - tokio::runtime::task::core::CoreStage<T>::poll::hf904e838099a0afd
  70:        0x101f9b260 - tokio::runtime::task::harness::poll_future::***closure***::h78bfc8876bbe5c29
  71:        0x101f0de9d - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h927e6dbd327b5b30
  72:        0x101d71f16 - std::panicking::try::do_call::hf22cfdadc0f0688b
  73:        0x101dbdb2d - ___rust_try
  74:        0x101d618ff - std::panicking::try::h3f9b8c8b3c356328
  75:        0x1024361d4 - std::panic::catch_unwind::h083da21b9020a39b
  76:        0x101f92e6c - tokio::runtime::task::harness::poll_future::h163515ba80400977
  77:        0x101fa9368 - tokio::runtime::task::harness::Harness<T,S>::poll_inner::hfff8f6ce6bd3d080
  78:        0x101fc3a05 - tokio::runtime::task::harness::Harness<T,S>::poll::hd4c5a5b589a485a7
  79:        0x102574c6a - tokio::runtime::task::raw::poll::h449eac42f38fa0b3
  80:        0x1057f692a - tokio::runtime::task::raw::RawTask::poll::hd5a1994d120442d9
  81:        0x105831e06 - tokio::runtime::task::UnownedTask<S>::run::h243bb8da4999282e
  82:        0x105869749 - tokio::runtime::blocking::pool::Task::run::h5ed09430e353db80
  83:        0x10586c05c - tokio::runtime::blocking::pool::Inner::run::h563ea28388842aca
  84:        0x10586b672 - tokio::runtime::blocking::pool::Spawner::spawn_thread::***closure***::haecfdf463c4d8604
  85:        0x10585d350 - std::sys_common::backtrace::__rust_begin_short_backtrace::h46271379a900d596
  86:        0x10584c450 - std::thread::Builder::spawn_unchecked_::***closure***::***closure***::hc5e651f040ba6378
  87:        0x10584a8b0 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h2dc0fce23982cac2
  88:        0x10580097d - std::panicking::try::do_call::h3874b8ef85f73960
  89:        0x105803f2d - ___rust_try
  90:        0x1057fdc27 - std::panicking::try::h738af07656a00449
  91:        0x1058be210 - std::panic::catch_unwind::h546b4319c1f47e8b
  92:        0x10584c2b3 - std::thread::Builder::spawn_unchecked_::***closure***::h866be6487715d92f
  93:        0x1057e435d - core::ops::function::FnOnce::call_once***vtable.shim***::hf11d651bff4e0760
  94:        0x106e8d517 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6b6f593edb7fb044
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/boxed.rs:1951:9
  95:        0x106e8d517 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha3bd0a5bf4aaac12
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/boxed.rs:1951:9
  96:        0x106e8d517 - std::sys::unix::thread::Thread::new::thread_start::hf7c5ae502e9a7ed8
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys/unix/thread.rs:108:17
  97:     0x7ff80a8114e1 - __pthread_start
```