Skip to content

Runtime panic when compiled as wasm and run in browser since 0.51 #506

@psychon

Description

@psychon

Hi,

using russh 0.51.1, wasm support does not work for me. I reproduced this in a git version, specifically v0.51.1-9-gd7de9cb. The following patch makes things work again for me:

diff --git a/russh/src/client/mod.rs b/russh/src/client/mod.rs
index 8b78db2..cc8aec1 100644
--- a/russh/src/client/mod.rs
+++ b/russh/src/client/mod.rs
@@ -539,6 +539,7 @@ impl<H: Handler> Handle<H> {
     /// you can assume that it will return `None` every time.
     pub async fn best_supported_rsa_hash(&self) -> Result<Option<Option<HashAlg>>, Error> {
         // Wait for the extension info from the server
+        /*
         let (sender, receiver) = oneshot::channel();
         self.sender
             .send(Msg::AwaitExtensionInfo {
@@ -548,6 +549,7 @@ impl<H: Handler> Handle<H> {
             .await
             .map_err(|_| crate::Error::SendError)?;
         let _ = tokio::time::timeout(Duration::from_secs(1), receiver).await;
+        */

         let (sender, receiver) = oneshot::channel();

Without this patch, I get the following error in the browser console:

panicked at library/std/src/sys/pal/wasm/../unsupported/time.rs:13:9:
time not implemented on this platform

Stack:

[snip]
[wasm_ssh_websocket.wasm.std::time::Instant::now::h8765c2358e19e601@http://localhost:8000/pkg/wasm_ssh_websocket_bg.wasm:wasm-function](mailto:wasm_ssh_websocket.wasm.std::time::Instant::now::h8765c2358e19e601@http://localhost:8000/pkg/wasm_ssh_websocket_bg.wasm:wasm-function)[16327]:0x88f15e
[wasm_ssh_websocket.wasm.tokio::time::instant::variant::now::h027b466fbc7c6c8f@http://localhost:8000/pkg/wasm_ssh_websocket_bg.wasm:wasm-function](mailto:wasm_ssh_websocket.wasm.tokio::time::instant::variant::now::h027b466fbc7c6c8f@http://localhost:8000/pkg/wasm_ssh_websocket_bg.wasm:wasm-function)[13139]:0x860688
[wasm_ssh_websocket.wasm.tokio::time::instant::Instant::now::hbe2745fa30a0b2aa@http://localhost:8000/pkg/wasm_ssh_websocket_bg.wasm:wasm-function](mailto:wasm_ssh_websocket.wasm.tokio::time::instant::Instant::now::hbe2745fa30a0b2aa@http://localhost:8000/pkg/wasm_ssh_websocket_bg.wasm:wasm-function)[18240]:0x89f17c
[wasm_ssh_websocket.wasm.tokio::time::timeout::timeout::hb5ae27ee336487ab@http://localhost:8000/pkg/wasm_ssh_websocket_bg.wasm:wasm-function](mailto:wasm_ssh_websocket.wasm.tokio::time::timeout::timeout::hb5ae27ee336487ab@http://localhost:8000/pkg/wasm_ssh_websocket_bg.wasm:wasm-function)[4282]:0x70b7cf
wasm_ssh_websocket.wasm.russh::client::Handle<H>::best_supported_rsa_hash::{{[closure}}::hc54b8b75b807f0e7@http://localhost:8000/pkg/wasm_ssh_websocket_bg.wasm:wasm-function](mailto:closure}}::hc54b8b75b807f0e7@http://localhost:8000/pkg/wasm_ssh_websocket_bg.wasm:wasm-function)[181]:0x2b1bcb
[snip]

Previous versions did not have this problem. The problem was introduced in commit db5e5ba via the use of tokio::time::timeout.

Edit: The above is when trying to authenticate with an SSH key. Authentication with an OpenSSH certificate works fine. I did not test password auth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions