Repository navigation
LOC-7743: clear the log file using the unquoted path on Windows - #191
Draft
07souravkunda wants to merge 1 commit into
Draft
07souravkunda wants to merge 1 commit into
07souravkunda wants to merge 1 commit into
Conversation
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>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On Windows,
Localwraps the log path in double quotes for the binary's command line (sanitizePath). Since ee24820 swapped the shell-based clear (echo "" > <path>) forfs.writeFileSync(that.logfile, ''), the same quoted string also goes tofs. A path that starts with"is resolved relative to the current directory, so every Windowsstart/startSynclogs: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.logfilenow holds the raw path (constructor default and thelogfile/logFileoption). File operations use it as-is.getBinaryArgsappliessanitizePathwhen 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 throughcmd.exe /c startwith 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 likelocal_start_output_handling.js, and is skipped on Windows):startSyncandstartempty the log, with no "Could not clear log file". Both fail on master with the ENOENT above and pass with this change.--log-fileargument 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.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
logFilepointing 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