fix: avoid double-init of late final _root in NodeDriveService (1.27.4)#73
Merged
Conversation
The 1.27.3 MSYS mount-root translation assigned the `late final _root` field twice on Windows — once on resolve, again on translation — throwing `LateInitializationError` and crashing NodeDriveService right after the session began serving, on the exact Windows/MSYS path the 1.27.3 fix targeted. Root resolution now computes a single value via the pure, platform- parameterized `NodeDriveService.resolveRoot`, assigned to `_root` exactly once. Extracting the static helper also makes the Windows branch unit- testable off Windows; added test/unit/node/node_drive_service_test.dart. POSIX nodes were unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Starting a Windows node and opening a drive session crashed with:
This is a regression from #72 / commit
bcb029b("translate MSYS drive-mount root on Windows nodes", v1.27.3)._rootis declaredlate final String(one assignment only), but the new MSYS-translation code assigned it twice on Windows when the path starts with/:The crash fires on exactly the Windows + MSYS-root case the 1.27.3 fix was meant to support: the session opens, then the drive service dies, taking the node down.
Fix
Resolve the root into a single value via a pure, platform-parameterized static helper
NodeDriveService.resolveRoot(command, isWindows: ...), assigned to_rootexactly once. Extracting the helper also makes the Windows-only branch unit-testable off Windows.Tests
test/unit/node/node_drive_service_test.dartcovering MSYS translation on Windows, POSIX pass-through (regression guard), already-Windows / non-drive paths, null default, and idempotency.version_testpass;dart format+dart analyzeclean.Version
Bumped 1.27.3 -> 1.27.4 (
pubspec.yaml,lib/src/version.dart) + CHANGELOG entry.🤖 Generated with Claude Code