Skip to content

[Bug][Windows] Service wrapper fails to parse on locales where %DATE% contains parentheses (e.g. ja-JP); proxy never starts under Task Scheduler #5093

Closed as not planned

Description

@hashaseg9999-a11y

Summary

On Windows with a locale whose %DATE% contains parentheses (e.g. Japanese: 2026/09/19 (土)), the generated service wrapper ~/.opencodex/opencodex-service.cmd fails to parse and exits before launching Bun. The Task Scheduler job reports success (LastTaskResult = 0), but the proxy never starts. ocx service / ocx service repair then reports "registered but NOT serving".

Environment

  • opencodex 2.59.0 (upgraded from 2.46.0), Windows 11, ja-JP locale
  • Service backend: Task Scheduler (opencodex-proxy task)

Reproduction

  1. Use a Windows locale where %DATE% includes ( ) (ja-JP: 2026/09/19 (土)).
  2. Run ocx service (install/repair), or run the wrapper directly: cmd /c .\opencodex-service.cmd.

Actual result (stdout of the wrapper):

8:12:31.98] was unexpected at this time.

service.log only ever contains the top-level wrapper start header lines; no Bun output and no error line follow. Running the exact same bun <cli> start --port 10100 command by hand with OCX_SERVICE=1 works fine, so the failure is in the wrapper itself.

Root cause

src/service/windows-taskxml.ts emits echo [%DATE% %TIME%] ... inside parenthesised if (...) / for (...) blocks (the installation is incomplete, child exited with code, and restored previous install lines, roughly lines 101, 108, 113, 133). cmd.exe expands %DATE% while parsing the whole block, so the ) in (土) closes the block early and the rest of the line is a syntax error. The whole batch file is rejected at that point, so nothing after the header echo runs.

The top-level echo [%DATE% %TIME%] ... lines (outside any block) are unaffected, which is why the header line is still logged and the failure looks silent. This appears to have been introduced with the restore_backup / integrity-check blocks; the pre-2.5x wrapper started fine on the same machine.

Workaround / suggested fix

Inside blocks, replace %DATE% with a substring that cannot contain parentheses, e.g. %DATE:~0,10%:

-  >>"%OCX_SERVICE_LOG%" echo [%DATE% %TIME%] installation is incomplete: ...
+  >>"%OCX_SERVICE_LOG%" echo [%DATE:~0,10% %TIME%] installation is incomplete: ...

(same for the CLI-missing line, the child exited with code %ERRORLEVEL% line, and the restored previous install from %%B line). After patching the template and running ocx service repair, the scheduled task launches the proxy normally (verified: wscript -> cmd wrapper -> bun, /healthz reports 2.59.0).

A more robust alternative is a small :log subroutine called from the blocks so that %DATE% is only expanded at top level.

Related hardening

Because the wrapper exits 0 on a parse error, the Task Scheduler RestartOnFailure never triggers, and ocx service only says "no proxy answered". It might be worth having ocx service / ocx doctor smoke-test the generated wrapper (e.g. detect a ... was unexpected at this time. failure) and surface the real cause.

Activity

  1. added
    platform
    service
    on Sep 18, 2026
  2. github-actions commented on Sep 18, 2026

    @github-actions
    Contributor

    Issue closed: use an issue template

    Thanks for taking the time to submit this issue. It was closed automatically because it was not opened with a recognized issue template (Bug report, Feature request, Documentation, or Provider compatibility). Freeform and API-opened issues cannot skip this check.

    • This looks like a bug report but it does not use the Bug report template headings (for example Description/Log entry instead of Summary).

    Please edit the issue to add:

    • Use the Bug report template, or edit this issue to include: Client or integration, Summary, Reproduction, Version, and Operating system.
    • Retitling with [Bug]: and applying the bug label alone is not enough without those section headings filled in.

    See the Contributing guide for details.

    Once the report passes the automated checks, it will be reopened automatically unless a maintainer has changed its state.

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

    platformservice

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions