Skip to content

[Bug]: Windows startup can run the 20 s schtasks fallback twice before listen #2923

Description

@Ingwannu

Confirmed current-dev regression

Current dev 64b994c includes #2918. On Windows, a localized nonzero targeted schtasks query falls back to the full task listing with a 20 second ceiling.

startServer currently calls inspectStartupOwnership before startup cache invalidation at src/server/index.ts around line 609 and again before native-main lifecycle preparation around line 788. Both calls reach the same synchronous service-manager probe.

On the reported zh-CN host, the full listing measured about 12.3 seconds for 401 tasks. With no installed OpenCodex task, one proxy start can therefore spend about 25 seconds in two identical listings before Bun.serve starts, with a 40 second worst-case ceiling.

The second ownership check is intentional. It prevents startup work between the cache decision and native lifecycle preparation from widening the service-install race. The fix must not simply delete final revalidation, lower the listing timeout back to 2 seconds, add guessed absence, or convert an unknown result into absent.

Required scope

  • Keep each final ownership decision fail-closed.
  • Keep the targeted scheduled-task query bounded and revalidated.
  • Avoid repeating the expensive full-machine enumeration during one startup when the targeted recheck still provides the race-sensitive evidence.
  • Do not broaden this into service installation or GUI changes.

Regression coverage

Add an injected Windows startup probe that:

  1. makes the targeted query return a localized unreadable nonzero result,
  2. makes the full listing take the fallback path,
  3. proves one start does not run the full listing twice,
  4. proves the targeted ownership recheck still occurs, and
  5. proves a task that becomes present between checks is not reported absent.

Original review evidence: #2920 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplatformOS/service/tray/ACL (Windows-heavy, not Windows-only)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions