{"record":{"id":"6583703769ed1ede","repo":"tursodatabase/turso","slug":"unexpectedeof-658370","errorCode":"UnexpectedEof","errorMessage":"Reading past the EOF point","messagePattern":"Reading past the EOF point","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"core/io/win_iocp.rs","lineNumber":657,"sourceCode":"                    get_unique_key_from_completion(&completion).addr()\n                );\n                completion.complete(\n                    bytes_received\n                        .try_into()\n                        .map_err(|_| GetIOCPPacketError::InvalidIO)?,\n                );\n            }\n            (FALSE, ERROR_OPERATION_ABORTED) => {\n                trace!(\n                    \"completion {} cancelled\",\n                    get_unique_key_from_completion(&completion).addr()\n                );\n                completion.abort();\n            }\n            (FALSE, error_code) => {\n                let error = match error_code {\n                    ERROR_HANDLE_EOF => {\n                        io::Error::new(io::ErrorKind::UnexpectedEof, \"Reading past the EOF point\")\n                    }\n                    code => io::Error::from_raw_os_error(\n                        code.try_into().map_err(|_| GetIOCPPacketError::InvalidIO)?,\n                    ),\n                };\n\n                trace!(\n                    \"completion {} errored {error}\",\n                    get_unique_key_from_completion(&completion).addr()\n                );\n\n                completion.error(CompletionError::IOError(\n                    error.kind(),\n                    \"io-error-completion\",\n                ));\n            }\n            (_, _) => unreachable!(),\n        }","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/core/io/win_iocp.rs#L639-L675","documentation":"Windows IOCP driver: a completed read that ended with ERROR_HANDLE_EOF is translated to UnexpectedEof (\"Reading past the EOF point\") - the async read asked for bytes beyond the file's end, so the OS completed it with fewer or zero bytes.","triggerScenarios":"A Windows read issued with a length computed from stale file size: the file was truncated concurrently by another process, the WAL shrank between the size check and the read, or the db header claims more pages than the file holds.","commonSituations":"Another process (backup, AV, editor) truncates or locks the database or WAL mid-run; a crash left the header size inconsistent with the file; or a read past the last page.","solutions":["Verify no external tool truncates or locks the db and WAL files (add AV exclusions)","Re-check the file size immediately before issuing reads sized from earlier metadata","If a header/size mismatch persists, restore from backup or re-create the database","Handle UnexpectedEof on Windows reads as a truncation signal: reopen and recover instead of retrying blindly"],"exampleFix":"// before\nio.read_exact_at(buf, off).await; // sized from stale metadata\n// after\nlet len = io.size().await;\nif off + buf.len() > len {\n    return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, \"range beyond file\"));\n}\nio.read_exact_at(buf, off).await;","handlingStrategy":"validation","validationCode":"let file_len = std::fs::metadata(&path)?.len() as usize;\nif range.end > file_len {\n    return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, \"range beyond current file size\"));\n}","typeGuard":null,"tryCatchPattern":"match io.read(...) { Err(ref e) if e.kind() == std::io::ErrorKind::UnexpectedEof => recover_or_reopen(), r => r }","preventionTips":["Re-check file size immediately before large reads","Exclude database files from AV/backup interference on Windows","Treat UnexpectedEof on Windows reads as truncation, not a transient error"],"tags":["windows","iocp","eof","async-io","rust"],"backgroundTag":"unexpected-eof","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}