Skip to content

fix(tegg): preserve load error caller path - #5939

Merged
killagu merged 2 commits into
nextfrom
agent/egg-dev/417ded38
Oct 6, 2026
Merged

killagu merged 2 commits into
nextfrom
agent/egg-dev/417ded38

Conversation

@killagu

@killagu killagu commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Preserve the original caller-provided file path when wrapping tegg dynamic import failures.
  • Add regression coverage for the Windows file URL fallback path.

Tests

  • pnpm exec vitest run tegg/core/loader/test/Loader.test.ts
  • pnpm -C tegg/core/loader run typecheck
  • pnpm exec oxlint --type-aware tegg/core/loader/src/LoaderUtil.ts tegg/core/loader/test/Loader.test.ts
  • pnpm exec oxfmt --check tegg/core/loader/src/LoaderUtil.ts tegg/core/loader/test/Loader.test.ts
  • git diff --check origin/next...HEAD

Follow-up for CodeRabbit thread on #5932.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed module-load error messages on Windows to report the original file path when loading fails.
  • Tests

    • Added coverage for Windows-specific error handling.

Copilot AI review requested due to automatic review settings May 7, 2026 18:12
@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 62a99685-1bbb-4dd7-ac29-90c3e0c3fcf8
📥 Commits

Reviewing files that changed from the base of the PR and between 444f6eb and 081f7c3.

📒 Files selected for processing (2)
  • tegg/core/loader/src/LoaderUtil.ts
  • tegg/core/loader/test/Loader.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

LoaderUtil adds a Windows platform check and uses it during file loading. If a dynamic import fails, the wrapped error uses the original input path. A test checks the Windows error message and cause.

Changes

Windows File Path Preservation

Layer / File(s) Summary
Windows platform check
tegg/core/loader/src/LoaderUtil.ts
Adds static isWindowsPlatform(): boolean, which reports whether the current platform is Windows.
Import error handling and test
tegg/core/loader/src/LoaderUtil.ts, tegg/core/loader/test/Loader.test.ts
Uses the helper for Windows path conversion. If dynamic import fails, the error wrapper receives the original input path. The test checks the wrapped message, cause, and platform-helper call count. It also restores the spy and loader globals.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: elrrrrrrr

Merge Risk: ⚪ Minimal · up to 081f7

No actionable issue remains from this review; the change is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preserving the caller-provided path in load errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 7, 2026 •

Copy link
Copy Markdown

Deploying egg with  Cloudflare Pages  Cloudflare Pages

Latest commit: 081f7c3
Status: ✅  Deploy successful!
Preview URL: https://da5b8b9e.egg-cci.pages.dev
Branch Preview URL: https://agent-egg-dev-417ded38.egg-cci.pages.dev

View logs

@codecov

codecov Bot commented May 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.91%. Comparing base (be66a84) to head (081f7c3).
⚠️ Report is 2 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #5939      +/-   ##
==========================================
+ Coverage   80.24%   83.91%   +3.67%     
==========================================
  Files           4      731     +727     
  Lines         329    22602   +22273     
  Branches       91     4554    +4463     
==========================================
+ Hits          264    18967   +18703     
- Misses         56     3141    +3085     
- Partials        9      494     +485     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates LoaderUtil.ts to use originalFilePath instead of filePath when reporting load errors, ensuring consistent error messages across different environments. A new test case was added to verify this behavior on Windows. Feedback was provided regarding the method used to mock process.platform in the tests, suggesting a more robust approach like using a helper method or standard mocking tools to avoid potential fragility in different Node.js environments.

Comment thread tegg/core/loader/test/Loader.test.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes TEgg loader error wrapping so that, when LoaderUtil.loadFile() falls back to import() on Windows and converts the path to a file:// URL, the thrown “load failed” error message still references the original caller-provided path (not the transformed URL). It also adds a regression test to ensure this behavior.

Changes:

  • Use originalFilePath (caller path) instead of the potentially rewritten filePath when wrapping dynamic import() failures.
  • Add a regression test that simulates win32 and asserts the error message preserves the caller path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tegg/core/loader/src/LoaderUtil.ts Preserve caller-provided path in createLoadError(...) when dynamic import fails after Windows file:// conversion.
tegg/core/loader/test/Loader.test.ts Add regression coverage ensuring error messages keep the original path under the win32 fallback branch.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 7, 2026 •

Copy link
Copy Markdown

Deploying egg-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 081f7c3
Status:⚡️  Build in progress...

View logs

@killagu
killagu force-pushed the agent/egg-dev/417ded38 branch from 09214b3 to 444f6eb Compare May 7, 2026 18:48
Copilot AI balanced review requested due to automatic review settings October 6, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@killagu
killagu merged commit 604d448 into next Oct 6, 2026
33 of 35 checks passed
@killagu
killagu deleted the agent/egg-dev/417ded38 branch October 6, 2026 11:29
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.

2 participants