Skip to content

fix: should handle loader error with empty stack trace#12213

Merged
SyMind merged 3 commits intomainfrom
fix-throw-error-in-loader
Nov 17, 2025
Merged

fix: should handle loader error with empty stack trace#12213
SyMind merged 3 commits intomainfrom
fix-throw-error-in-loader

Conversation

@SyMind
Copy link
Copy Markdown
Member

@SyMind SyMind commented Nov 17, 2025

Summary

  1. Fix issue [Bug]: loader error message missing of mdx-loader #12080 by properly handling loader errors that have an empty stack trace.
  2. Improve ModuleBuildError to print current loader path.
ERROR in ./lib.js
  × Module build failed (from ./my-loader.js):
  ╰─▶   × Failed to load

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Nov 17, 2025
@netlify
Copy link
Copy Markdown

netlify bot commented Nov 17, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 2d91e18
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/691ab47516a32c000887f0e2

@SyMind SyMind force-pushed the fix-throw-error-in-loader branch from d7ee052 to b213c37 Compare November 17, 2025 03:15
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 17, 2025

📦 Binary Size-limit

Comparing 2d91e18 to chore(deps): update dependency emnapi to ^1.7.1 (#12157) by renovate[bot]

❌ Size increased by 896bytes from 47.46MB to 47.46MB (⬆️0.00%)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 17, 2025

CodSpeed Performance Report

Merging #12213 will not alter performance

Comparing fix-throw-error-in-loader (2d91e18) with main (dceb4c7)

Summary

✅ 17 untouched

@SyMind SyMind marked this pull request as ready for review November 17, 2025 04:01
Copilot AI review requested due to automatic review settings November 17, 2025 04:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 issue #12080 by properly handling loader errors that have an empty stack trace. When a loader throws an error with stack = "", the system now correctly falls back to displaying the error message instead of attempting to use the empty stack string.

  • Added empty stack check in error display logic
  • Removed unused details variable computation in loader scheduler
  • Added diagnostic test case to verify empty stack trace handling

Reviewed Changes

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

Show a summary per file
File Description
crates/rspack_binding_api/src/error.rs Added check for empty stack string before using it in Display implementation
crates/rspack_binding_api/src/plugins/js_loader/scheduler.rs Removed unused details variable that was computed but never used
tests/rspack-test/diagnosticsCases/module-build-failed/loader-throw-empty-stack-error/index.js Test entry point that requires a non-existent module to trigger loader error
tests/rspack-test/diagnosticsCases/module-build-failed/loader-throw-empty-stack-error/my-loader.js Custom loader that throws an error with empty stack trace
tests/rspack-test/diagnosticsCases/module-build-failed/loader-throw-empty-stack-error/rspack.config.js Rspack configuration to apply the custom loader
tests/rspack-test/diagnosticsCases/module-build-failed/loader-throw-empty-stack-error/stats.err Expected error output showing module not found error
tests/rspack-test/diagnosticsCases/module-build-failed/loader-throw-empty-stack-error/raw-error.err Expected raw error format
tests/rspack-test/diagnosticsCases/module-build-failed/loader-throw-empty-stack-error/raw-warning.err Expected raw warning format (empty array)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SyMind SyMind requested a review from h-a-n-a as a code owner November 17, 2025 04:09
@SyMind SyMind merged commit 09a4d48 into main Nov 17, 2025
47 checks passed
@SyMind SyMind deleted the fix-throw-error-in-loader branch November 17, 2025 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants