{"record":{"id":"57b1b1d9411550d2","repo":"gitbutlerapp/gitbutler","slug":"system-clock-is-before-the-unix-epoch-err","errorCode":null,"errorMessage":"system clock is before the Unix epoch: {err}","messagePattern":"system clock is before the Unix epoch: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/workspace.rs","lineNumber":127,"sourceCode":"                    .iter()\n                    .find_map(|(_, err)| err.custom_context().map(|ctx| ctx.code));\n                let joined = failures\n                    .iter()\n                    .map(|(remote, err)| format!(\"{remote}: {err}\"))\n                    .collect::<Vec<_>>()\n                    .join(\"\\n\");\n                let err = anyhow::anyhow!(joined);\n                Err(match code {\n                    Some(code) => err.context(code),\n                    None => err,\n                })\n            }\n        }\n    })();\n\n    let attempted_ms = SystemTime::now()\n        .duration_since(UNIX_EPOCH)\n        .map_err(|err| anyhow::anyhow!(\"system clock is before the Unix epoch: {err}\"))?\n        .as_millis()\n        .try_into()\n        .map_err(|err| anyhow::anyhow!(\"fetch timestamp does not fit in the database: {err}\"))?;\n    let _guard = ctx.exclusive_worktree_access();\n    match &fetch_result {\n        Ok(()) => ctx\n            .db\n            .get_cache_mut()?\n            .fetch_status_mut()\n            .record_success(attempted_ms)?,\n        Err(err) => ctx\n            .db\n            .get_cache_mut()?\n            .fetch_status_mut()\n            .record_failure(attempted_ms, &format!(\"{err:#}\"))?,\n    }\n\n    // A partial failure may still have updated some remote refs.","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/2497b8007aa4a1922dae9a805b32ffe5b5037785/crates/but-api/src/workspace.rs#L109-L145","documentation":"Before recording the outcome of a workspace fetch, but-api stamps the attempt with SystemTime::now().duration_since(UNIX_EPOCH) in milliseconds. If the host clock reads before 1970-01-01 the duration is negative and duration_since returns Err, which this message wraps. It is purely an environment defect — a healthy machine cannot produce it — and it only affects the fetch-status bookkeeping timestamp.","triggerScenarios":"A workspace fetch (any API path reaching the fetch routine in crates/but-api/src/workspace.rs) on a host whose clock is set before the Unix epoch: dead RTC battery, a VM resumed with a reset clock, or a manually wrong date.","commonSituations":"Laptops with failed CMOS batteries; freshly cloned VMs before NTP or guest-tools sync; offline rigs with the date set wrong; CI sandboxes with mocked clocks.","solutions":["Fix the host clock and enable NTP (e.g. timedatectl set-ntp true on Linux).","Verify with `date -u` that time reads post-1970, then retry the fetch.","In VMs, install guest additions/vmtools or restart the guest to resync the clock."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (Date.now() < 0) {\n  throw new Error('system clock is set before 1970; fix host time and enable NTP');\n}","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (String(e.message).includes('system clock is before the Unix epoch')) {\n    showFatalError('Host clock invalid', 'Set the correct date, enable time synchronization, then retry.');\n  }\n}","preventionTips":["Enable NTP on dev machines, CI runners, and VMs.","Check `date -u` in CI boot scripts before network suites.","Install VM guest tools for clock sync on cloned or restored guests."],"tags":["system-clock","time","environment","fetch"],"backgroundTag":"system-clock-before-epoch","analyzedSha":"2497b8007aa4a1922dae9a805b32ffe5b5037785","analyzedAt":"2026-08-17T00:30:25.648Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}