Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upIntermittent Panic when connecting to Websockets server after refresh #26977
Comments
|
I tried to follow those steps and ended up with:
when loading localhost:3000 in Firefox. |
|
@jdm that will happen if the front-end build hasn't finished yet. It's a big project, so it might take a bit. You'll see a bunch of reloads and then a big output asset list which should include |
|
My mistake, I forgot to set up the docker file sharing. I'm seeing something that looks like content now. |
|
This looks like a straightforward fix, which I'm in the process of testing: this code runs off the script thread, and shouldn't make any assumptions that the thread it wants to send events to is still alive. The unwrap calls aren't appropriate there and are causing a panic, which ends up bringing down the rest of the browser in a cascade. |
diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs
index 89aeda77eb..9d2f6c5dd3 100644
--- a/components/script/dom/websocket.rs
+++ b/components/script/dom/websocket.rs
@@ -68,7 +68,7 @@ mod close_code {
pub const TLS_FAILED: u16 = 1015;
}
-pub fn close_the_websocket_connection(
+fn close_the_websocket_connection(
address: Trusted<WebSocket>,
task_source: &WebsocketTaskSource,
canceller: &TaskCanceller,
@@ -81,12 +81,11 @@ pub fn close_the_websocket_connection(
code: code,
reason: Some(reason),
};
- task_source
- .queue_with_canceller(close_task, &canceller)
- .unwrap();
+ let _ = task_source
+ .queue_with_canceller(close_task, &canceller);
}
-pub fn fail_the_websocket_connection(
+fn fail_the_websocket_connection(
address: Trusted<WebSocket>,
task_source: &WebsocketTaskSource,
canceller: &TaskCanceller,
@@ -97,9 +96,8 @@ pub fn fail_the_websocket_connection(
code: Some(close_code::ABNORMAL),
reason: None,
};
- task_source
- .queue_with_canceller(close_task, &canceller)
- .unwrap();
+ let _ = task_source
+ .queue_with_canceller(close_task, &canceller);
}
#[dom_struct]
@@ -221,18 +219,16 @@ impl WebSocket {
address: address.clone(),
protocol_in_use,
};
- task_source
- .queue_with_canceller(open_thread, &canceller)
- .unwrap();
+ let _ = task_source
+ .queue_with_canceller(open_thread, &canceller);
},
WebSocketNetworkEvent::MessageReceived(message) => {
let message_thread = MessageReceivedTask {
address: address.clone(),
message: message,
};
- task_source
- .queue_with_canceller(message_thread, &canceller)
- .unwrap();
+ let _ = task_source
+ .queue_with_canceller(message_thread, &canceller);
},
WebSocketNetworkEvent::Fail => {
fail_the_websocket_connection(address.clone(), &task_source, &canceller);This makes the panic disappear for me, and gives me a page I can interact with after reloading. I'm going to try to write an automated test that tickles this as well. |
Details
Servo sometimes crashes during a WebSockets connection to a Socket.io server. In particular, it seems to happen during a reload and not during a fresh start.
Might be related to #26097 (comment), but I'm not sure.
Error Message:
Reproduction Steps
git clone https://github.com/casual-simulation/casualosservo-fixesbranch.cd casualosgit checkout servo-fixesnpm run watchhttp://localhost:3000./mach run http://localhost:3000 --devtools 6000Layout thread disconnected.: "SendError(..)" (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(1) }, at components/script/dom/window.rs:1699)System Details
Operating System: MacOS 10.15.4
Servo Version: 1b55ab5
Rustc Version:
rustc 1.45.0-nightly (a74d1862d 2020-05-14)Logs
Crash Logs