{"record":{"id":"e1e1a495a27a5521","repo":"iced-rs/iced","slug":"send-event","errorCode":null,"errorMessage":"Send event","messagePattern":"Send event","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"winit/src/lib.rs","lineNumber":269,"sourceCode":"        fn about_to_wait(&mut self, event_loop: &winit::event_loop::ActiveEventLoop) {\n            self.process_event(\n                event_loop,\n                Event::EventLoopAwakened(winit::event::Event::AboutToWait),\n            );\n        }\n    }\n\n    impl<Message> Runner<Message> {\n        fn process_event(\n            &mut self,\n            event_loop: &winit::event_loop::ActiveEventLoop,\n            event: Event<Action<Message>>,\n        ) {\n            if event_loop.exiting() {\n                return;\n            }\n\n            self.sender.start_send(event).expect(\"Send event\");\n\n            loop {\n                let poll = self.instance.as_mut().poll(&mut self.context);\n\n                match poll {\n                    task::Poll::Pending => match self.receiver.try_recv() {\n                        Ok(control) => match control {\n                            Control::ChangeFlow(flow) => {\n                                use winit::event_loop::ControlFlow;\n\n                                match (event_loop.control_flow(), flow) {\n                                    (\n                                        ControlFlow::WaitUntil(current),\n                                        ControlFlow::WaitUntil(new),\n                                    ) if current < new => {}\n                                    (ControlFlow::WaitUntil(target), ControlFlow::Wait)\n                                        if target > Instant::now() => {}\n                                    _ => {","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/iced-rs/iced/blob/d146509d893945de5c304cfaf4301335eee278bd/winit/src/lib.rs#L251-L287","documentation":"The winit runtime's event pump asserts that start_send on a channel to the application's event processor succeeds. This fails only when the channel's receiver has been dropped - i.e. the other half of the Proxy/pump pipeline shut down - which iced treats as an unrecoverable internal state violation during process_event.","triggerScenarios":"An event (window_event, user_event, new_events, etc.) is dispatched while the receiving side of the mpsc channel (self.receiver's owner) has already been dropped, typically after shutdown/exit began but before the event loop stopped, or from a Proxy send racing application teardown.","commonSituations":"Sending messages from a subscription/task right as the window closes; programmatic exit() from user code followed by in-flight events; multi-window setups where one window's close tears down the pump while events still arrive.","solutions":["Avoid sending events/messages after initiating application exit; guard async tasks/subscriptions with a cancellation flag checked on completion.","Check that tasks spawned via the Proxy don't outlive the program (join/abort them on shutdown).","Upgrade iced - teardown races in the winit runtime have been fixed across releases.","If reproducible, capture the exact sequence (exit + pending event) and restructure so the exit is processed via a message rather than directly stopping the loop."],"exampleFix":"// before\nself.sender.start_send(event).expect(\"Send event\");\n// after (caller-side guard before exiting)\nif !exiting {\n    proxy.send_event(ev).ok();\n}","handlingStrategy":"try-catch","validationCode":"// before sending from a task, check the program is still running\nif app_is_running.load(std::sync::atomic::Ordering::Relaxed) {\n    proxy.send_event(ev).ok();\n}","typeGuard":null,"tryCatchPattern":"// treat send failure as shutdown, not a crash\nmatch sender.start_send(event) {\n    Ok(()) => { /* continue */ }\n    Err(_) => return, // receiver gone: event loop is shutting down\n}","preventionTips":["Abort or join long-running tasks on application exit.","Use a cancellation flag checked by async subscriptions before sending.","Prefer sending a shutdown Message over directly stopping the loop.","Keep iced updated - teardown races are fixed periodically."],"tags":["winit","channel","panic","shutdown-race"],"backgroundTag":"broken-pipe","analyzedSha":"d146509d893945de5c304cfaf4301335eee278bd","analyzedAt":"2026-09-11T16:54:14.229Z","contentChangedAt":"2026-09-11T16:54:14.229Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}