Skip to content

Fix restart delay operator precedence and status KV write initialization#80

Draft
Copilot wants to merge 2 commits into
devfrom
copilot/fix-low-hanging-fruit
Draft

Fix restart delay operator precedence and status KV write initialization#80
Copilot wants to merge 2 commits into
devfrom
copilot/fix-low-hanging-fruit

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 20, 2026

Two bugs in process lifecycle management: restartDelayMs was silently ignored when watch was also configured, and application state was not persisted to KV store for the first 20 seconds after startup.

Operator precedence: restartDelayMs ignored when watch is set

?? has higher precedence than ?:, so the intended fallback expression was evaluated incorrectly:

// Was parsed as: (config.restartDelayMs ?? config.watch) ? 500 : 10000
const baseRestartDelay = config.restartDelayMs ?? config.watch ? 500 : 10000

// Fixed:
const baseRestartDelay = config.restartDelayMs ?? (config.watch ? 500 : 10000)

Any process with both restartDelayMs and watch configured would always restart with a 500ms delay regardless of the configured value.

Status KV write skipped for first 20 seconds

lastWrite was initialized to Date.now(), causing Date.now() - this.lastWrite > APPLICATION_STATE_WRITE_LIMIT_MS to be false on every watchdog tick until 20 seconds had elapsed. Changed initialization to 0 so the first write happens on the first watchdog tick. Also removed the now-unreachable if (!this.lastWrite) dead code block, and corrected the misleading docblock that claimed last_application_state was written on every iteration.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.deno.land
    • Triggering command: /usr/bin/curl curl -s REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…ialization

Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
Copilot AI changed the title [WIP] Review issues and fix low hanging fruit Fix restart delay operator precedence and status KV write initialization Feb 20, 2026
Copilot AI requested a review from Hexagon February 20, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants