{"record":{"id":"0a072d485d0f8f94","repo":"DioxusLabs/dioxus","slug":"sse-should-be-initialized-before-using-it-as-a-res","errorCode":null,"errorMessage":"SSE should be initialized before using it as a response","messagePattern":"SSE should be initialized before using it as a response","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/fullstack/src/payloads/sse.rs","lineNumber":355,"sourceCode":"        /// Create a `ServerEvents` from an existing Axum `Sse` response.\n        #[allow(clippy::type_complexity)]\n        pub fn from_sse(\n            sse: Sse<Pin<Box<dyn Stream<Item = Result<Event, BoxError>> + Send>>>,\n        ) -> Self {\n            Self {\n                _marker: std::marker::PhantomData,\n                client: None,\n                keep_alive: None,\n                sse: Some(sse),\n            }\n        }\n    }\n\n    impl<T> IntoResponse for ServerEvents<T> {\n        fn into_response(self) -> axum_core::response::Response {\n            let sse = self\n                .sse\n                .expect(\"SSE should be initialized before using it as a response\");\n\n            if let Some(keep_alive) = self.keep_alive {\n                sse.keep_alive(keep_alive).into_response()\n            } else {\n                sse.into_response()\n            }\n        }\n    }\n\n    /// A transmitter for sending events to the SSE stream.\n    pub struct SseTx<T> {\n        sender: futures_channel::mpsc::UnboundedSender<axum::response::sse::Event>,\n        _marker: std::marker::PhantomData<fn() -> T>,\n    }\n\n    impl<T: Serialize> SseTx<T> {\n        /// Sends an event to the SSE stream.\n        pub async fn send(&mut self, event: T) -> anyhow::Result<()> {","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/fullstack/src/payloads/sse.rs#L337-L373","documentation":"`ServerEvents::into_response` requires the SSE stream to have been initialized (via `from_sse` or the client constructor); it `expect`s the inner Option to hold an Sse. This panic fires when an uninitialized `ServerEvents` (no stream and no client) is used directly as an axum response.","triggerScenarios":"Thrown at packages/fullstack/src/payloads/sse.rs:355 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Initialize the SSE stream (e.g. via the provided SSE constructor) before using it as a server function response."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}