{"record":{"id":"c5bd53d7bbf35270","repo":"flxzt/rnote","slug":"channel-closed-before-receiving-a-response-from-di","errorCode":null,"errorMessage":"Channel closed before receiving a response from dialog.","messagePattern":"Channel closed before receiving a response from dialog\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/rnote-ui/src/dialogs/import.rs","lineNumber":564,"sourceCode":"                        if let Err(e) = tx_import.unbounded_send(Ok(true)) {\n                            error!(\n                                \"PDF file imported, but failed to send signal through channel. Err: {e:?}\"\n                            );\n                        }\n                    }\n                ));\n\n                match rx_import.next().await {\n                    Some(res) => res,\n                    None => Err(anyhow::anyhow!(\n                        \"Channel closed before receiving a response from loader thread.\"\n                    )),\n                }\n            } else {\n                Ok(false)\n            }\n        }\n        None => Err(anyhow::anyhow!(\n            \"Channel closed before receiving a response from dialog.\"\n        )),\n    }\n}\n\n/// Imports the file as Xopp with an import dialog.\n///\n/// Returns true when the file was imported, else false.\npub(crate) async fn dialog_import_xopp_w_prefs(\n    appwindow: &RnAppWindow,\n    canvas: &RnCanvas,\n    input_file: gio::File,\n) -> anyhow::Result<bool> {\n    let builder = Builder::from_resource(\n        (String::from(config::APP_IDPATH) + \"ui/dialogs/import.ui\").as_str(),\n    );\n    let dialog: adw::Dialog = builder.object(\"dialog_import_xopp_w_prefs\").unwrap();\n    let dpi_row: adw::SpinRow = builder.object(\"xopp_import_dpi_row\").unwrap();","sourceCodeStart":546,"sourceCodeEnd":582,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-ui/src/dialogs/import.rs#L546-L582","documentation":"Thrown when the password dialog's response channel closes before a response arrives, i.e. `rx.borrow_mut().recv()` in `dialog_import_pdf_w_prefs` returned None because the dialog's sender was dropped without the user answering. The function cannot proceed with import, so it errors instead of silently succeeding.","triggerScenarios":"In `dialog_import_pdf_w_prefs`, the PDF password dialog is dismissed in a way that does not emit a response (window destroyed, dialog cancelled by shutdown, response sender dropped) so `pdf_password_dialog` future resolves to None.","commonSituations":"User closes the parent window while the password dialog is open; dialog cancelled programmatically; a bug where the dialog's FutureExt::map handling never forwards a response before teardown.","solutions":["Treat dialog dismissal (cancel/close) as a user-abort and return Ok(false) rather than an error, if abort is acceptable.","Ensure the dialog always emits a response signal on cancel and the channel sender outlives the dialog lifetime.","Retry the import flow by re-invoking the import; if persistent, check dialog construction/lifecycle code.","Log which dismissal path occurred to distinguish user cancel from unexpected teardown."],"exampleFix":"// before\nNone => Err(anyhow::anyhow!(\"Channel closed before receiving a response from dialog.\")),\n// after\nNone => {\n    tracing::debug!(\"PDF password dialog closed without a response; aborting import\");\n    Ok(false)\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match dialog_response {\n    Some(pwd) => import_with_password(pwd),\n    None => Ok(false), // treat as user abort\n}","preventionTips":["Treat dialog dismissal as user cancellation, not a hard error","Ensure cancel/close also emits the response signal","Keep the response channel sender alive until the dialog is finalized"],"tags":["async","dialog","channel","pdf-import"],"backgroundTag":"broken-pipe","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}