{"record":{"id":"ab5c719c5d6edb9b","repo":"wasmerio/wasmer","slug":"the-page-is-non-empty","errorCode":null,"errorMessage":"The page is non-empty","messagePattern":"The page is non-empty","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/backend-api/src/query.rs","lineNumber":2366,"sourceCode":"\n                if page.is_empty() {\n                    if watch {\n                        /*\n                         * [TODO]: The resolution here should be configurable.\n                         */\n\n                        #[cfg(all(target_arch = \"wasm32\", target_os = \"unknown\"))]\n                        std::thread::sleep(Duration::from_secs(1));\n\n                        #[cfg(not(all(target_arch = \"wasm32\", target_os = \"unknown\")))]\n                        tokio::time::sleep(Duration::from_secs(1)).await;\n\n                        continue;\n                    }\n\n                    break Ok(None);\n                } else {\n                    let last_message = page.last().expect(\"The page is non-empty\");\n                    let timestamp = last_message.timestamp;\n                    // NOTE: adding 1 microsecond to the timestamp to avoid fetching\n                    // the last message again.\n                    let timestamp = OffsetDateTime::from_unix_timestamp_nanos(timestamp as i128)\n                        .with_context(|| {\n                            format!(\"Unable to interpret {timestamp} as a unix timestamp\")\n                        })?;\n\n                    // FIXME: We need a better way to tell the backend \"give me the\n                    // next set of logs\". Adding 1 nanosecond could theoretically\n                    // mean we miss messages if multiple log messages arrived at\n                    // the same nanosecond and the page ended midway.\n\n                    let next_timestamp = timestamp + Duration::from_nanos(1_000);\n\n                    break Ok(Some((page, next_timestamp)));\n                }\n            }","sourceCodeStart":2348,"sourceCodeEnd":2384,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/backend-api/src/query.rs#L2348-L2384","documentation":"In the backend-api GraphQL query paging logic, after filtering out messages from a fetched page, the code takes the last element with .expect(\"The page is non-empty\") to advance the pagination cursor. The library assumes that whenever it reaches this branch the page returned at least one message; if the page is empty at this point the invariant is violated and it panics.","triggerScenarios":"Calling code that queries a chat/message channel's last_message via the paginated query when the API returns a page where every entry is filtered out by the preceding conditions (e.g. all messages fail validation or are skipped), leaving page empty at the .last() call.","commonSituations":"Using wasmer backend-api tooling against a channel with only malformed/skipped messages, or an API schema change that makes the filter drop all items in a page.","solutions":["Upgrade wasmer-backend / wasmer to a version with fixed pagination edge-case handling","Check the channel data via the API directly; remove or repair the malformed message(s) that are being skipped","Retry the query later if the API is returning transient inconsistent pages","Work around by paginating manually with smaller page sizes so the filtered page is never fully empty"],"exampleFix":"// before\nlet last_message = page.last().expect(\"The page is non-empty\");\n// after\nlet last_message = match page.last() {\n    Some(m) => m,\n    None => break Ok(None),\n};","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// The panic occurs inside library query code; catch at the call boundary\nlet result = std::panic::catch_unwind(|| query_last_message(connector))\n    .map_err(|p| anyhow::anyhow!(\"last_message pagination panicked: {:?}\", p))?;","preventionTips":["Keep wasmer-backend-api versions in sync with the server API schema","Inspect channels with odd/all-filtered messages before querying last_message","Retry queries on API inconsistencies and report reproducible panics upstream","Validate API responses with smaller page sizes to expose empty-page cases early"],"tags":["panic","graphql","pagination","backend-api"],"backgroundTag":"unexpected-empty-page","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}