Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Build hangs on error when setting api: "modern-compiler" in sass-loader #9699

Open
Thiry1 opened this issue Mar 17, 2025 · 2 comments
Assignees
Labels
pending triage The issue/PR is currently untouched.

Comments

@Thiry1
Copy link
Contributor

Thiry1 commented Mar 17, 2025

System Info

System:
OS: macOS 14.7
CPU: (8) arm64 Apple M2
Memory: 90.69 MB / 24.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 22.14.0 - ~/.nodebrew/current/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.9.2 - ~/.nodebrew/current/bin/npm
pnpm: 8.15.3 - ~/.nodebrew/current/bin/pnpm
Browsers:
Chrome: 134.0.6998.89
Chrome Canary: 136.0.7072.0
Edge: 134.0.3124.68
Safari: 18.0
npmPackages:
@rspack/cli: ^1.2.8 => 1.2.8
@rspack/core: ^1.2.8 => 1.2.8

Details

Build hangs on error when setting api: "modern-compiler" in sass-loader.
In webpack, the process exits when an error occurs.
Removing the following setting allows the process to exit in rspack as well:

{
  loader: "sass-loader",
  options: {
-    api: "modern-compiler",
     implementation: require("sass-embedded"),
  }
}

Reproduce link

https://github.com/Thiry1/rspack-bug-repro/compare/hang-sass-loader

Reproduce Steps

  1. clone repro repo
  2. git switch hang-sass-loader
  3. npm i
  4. npm run build:rspack
@Thiry1 Thiry1 added the pending triage The issue/PR is currently untouched. label Mar 17, 2025
@Thiry1 Thiry1 changed the title [Bug]: Build Hangs on Error When Setting api: "modern-compiler" in sass-loader [Bug]: Build hangs on error when setting api: "modern-compiler" in sass-loader Mar 17, 2025
@Thiry1
Copy link
Contributor Author

Thiry1 commented Mar 17, 2025

I suspect that the issue is caused by the shutdown hook not being called on build errors, preventing sass-embedded from being disposed of.

I have confirmed that when Sass builds successfully, this hook is called and sass-embedded is properly disposed of.
https://github.com/webpack-contrib/sass-loader/blob/300ac87f3cd04183fd0d6ec9b931d52764d8ca64/src/utils.js#L775-L777

@Thiry1
Copy link
Contributor Author

Thiry1 commented Mar 19, 2025

According to the following comment, it seems that close is intentionally not called in case of an error. However, as a result, the shutdown hook is not triggered, and sass-embedded is not disposed of.

(error: Error | null, stats: Stats | MultiStats | undefined) => {
// If there is a compilation error, the close method should not be called,
// Otherwise Rspack may generate invalid caches.
if (error || stats?.hasErrors()) {
errorHandler(error, stats);
} else {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending triage The issue/PR is currently untouched.
Projects
None yet
Development

No branches or pull requests

2 participants