Fix Windows path handling in StructuredLogger#28
Merged
AJITHMELVIN merged 2 commits intocommerce-operations-foundation:developfrom Mar 18, 2026
Merged
Conversation
`new URL(import.meta.url).pathname` returns `/C:/Users/...` on Windows, causing `path.resolve` to produce invalid doubled drive letters like `C:\C:\Users\...` when resolving the log directory. Replace with `fileURLToPath(import.meta.url)` from the `url` module, which correctly handles Windows file URLs. Also use `path.sep` instead of hardcoded `/` for splitting the dist path, ensuring cross-platform compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
`import(absolutePath)` fails on Windows because Node.js ESM loader interprets the drive letter (e.g. `E:`) as a URL scheme. Convert the path to a file:// URL before importing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
I ended up doing the same change without realizing this PR was already raised. I am good with merging this change. |
f47cdf6
into
commerce-operations-foundation:develop
5 checks passed
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.
Summary
Two Windows path compatibility fixes in the server package:
StructuredLogger —
new URL(import.meta.url).pathnamereturns/C:/Users/...on Windows, causingpath.resolveto produce invalid doubled drive letters (C:\C:\Users\...\logs). Replaced withfileURLToPath(import.meta.url)andpath.sepfor cross-platform compatibility.AdapterFactory —
import(absolutePath)fails on Windows because Node.js ESM loader interprets the drive letter (e.g.E:) as a URL scheme (ERR_UNSUPPORTED_ESM_URL_SCHEME). AddedpathToFileURL()to convert native paths tofile://URLs before dynamic import.Problem
When running
@cof-org/mcpon Windows (e.g., via Claude Desktop), the server crashes on startup:Logger issue:
Adapter loading issue:
Fix
server/src/logging/structured-logger.ts— usefileURLToPath()+path.sepserver/src/adapters/adapter-factory.ts— usepathToFileURL().hreffor dynamic importsTest plan