Skip to content

LOC-7743: clear the log file using the unquoted path on Windows - #191

Draft
07souravkunda wants to merge 1 commit into
masterfrom
LOC-7743/clear-log-file-on-windows
Draft

07souravkunda wants to merge 1 commit into
masterfrom
LOC-7743/clear-log-file-on-windows

Conversation

@07souravkunda

@07souravkunda 07souravkunda commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Why

On Windows, Local wraps the log path in double quotes for the binary's command line (sanitizePath). Since ee24820 swapped the shell-based clear (echo "" > <path>) for fs.writeFileSync(that.logfile, ''), the same quoted string also goes to fs. A path that starts with " is resolved relative to the current directory, so every Windows start / startSync logs:

Could not clear log file:  ENOENT: no such file or directory, open 'C:\<cwd>\"C:\Users\<user>\...\local.log"'

The error is caught, so the tunnel still starts, but the previous log is never emptied. The binary opens the log in append mode, so a log at a reused path keeps growing. This affects every Windows consumer since 1.5.9, including the default cwd\local.log.

Change

  • this.logfile now holds the raw path (constructor default and the logfile / logFile option). File operations use it as-is.
  • getBinaryArgs applies sanitizePath when it builds --log-file. The argument the binary receives is byte-identical to before. The quotes stay deliberately: on Windows the binary re-spawns its daemon through cmd.exe /c start with verbatim arguments, so dropping them would risk splitting paths that contain spaces.

Tests

New test/local_log_file.js (forces the Windows quoting, uses shell stubs like local_start_output_handling.js, and is skipped on Windows):

  • startSync and start empty the log, with no "Could not clear log file". Both fail on master with the ENOENT above and pass with this change.
  • The --log-file argument stays quoted on Windows, isn't double-quoted when the caller already quoted it, and is unquoted on other platforms. These pass on master too: they pin the current command-line contract.

Run locally (macOS, Node 18.0.0):

  • mocha test/local_log_file.js test/local_start_output_handling.js test/local_binary_busy_download.js: 20 passing.
  • eslint lib/* index.js: clean.
  • An old-vs-new comparison of getBinaryArgs() over 10 option combinations (Windows + POSIX, including a path with spaces and a pre-quoted path) showed identical output.

Not run: a native Windows end-to-end start. Worth a quick check on a Windows box before release: start Local with logFile pointing at an existing non-empty file, then confirm the file is emptied, there's no "Could not clear log file" on stderr, and the tunnel connects.

Jira: LOC-7743

🤖 Generated with Claude Code

On Windows the log path is wrapped in double quotes for the binary's
command line. Since ee24820 replaced the shell `echo "" >` clear with
fs.writeFileSync, that quoted string also reached fs, which resolves a
path starting with `"` relative to the current directory. The clear
failed with ENOENT ("Could not clear log file") on every Windows start,
and the previous log was never emptied.

Keep this.logfile as the raw path and add the quotes only in
getBinaryArgs. The --log-file argument the binary receives is
unchanged.

Refs LOC-7743.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto (fallback from Default branch)
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML (base), Organization UI (inherited), Workspace UI (inherited); Enforced overrides: Organization
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: 907fc367-27f0-4443-b3ae-09dd52c07c29

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

1 participant