Skip to content

fix: disable server bundle minification for readable error stack traces#5162

Open
JorgeEscire wants to merge 1 commit intoDSpace:mainfrom
JorgeEscire:Issue/4124
Open

fix: disable server bundle minification for readable error stack traces#5162
JorgeEscire wants to merge 1 commit intoDSpace:mainfrom
JorgeEscire:Issue/4124

Conversation

@JorgeEscire
Copy link

References

Description

Disable minification for the server-side webpack bundle to produce readable error stack traces in production.

Instructions for Reviewers

List of changes in this PR:

  • Added optimization: { minimize: false } to webpack/webpack.prod.ts to disable minification of dist/server/main.js

How to test:

  1. Add throw new Error('hello world') anywhere in the body of server.ts to simulate an uncaught error
  2. Rebuild with yarn build:prod
  3. Start with yarn serve:ssr
  4. Before this fix: The entire minified file gets printed to the log, making it impossible to determine what went wrong
  5. After this fix: The stack trace shows the specific line where the error occurred, with readable code

Notes:

  • The server bundle only runs on the server and is never sent to browsers, so minification provides no benefit
  • mode: 'production' is preserved, so tree-shaking and other production optimizations remain active
  • The browser bundle (webpack.browser.ts) is unaffected and remains minified

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.

The production server bundle (dist/server/main.js) was minified, causing
Node.js to print the entire file in stack traces when uncaught exceptions
occurred. Since this bundle only runs on the server and is never sent to
browsers, minification provides no benefit. Tree-shaking and other
production optimizations remain active via mode: 'production'.
@lgeggleston lgeggleston added bug 1 APPROVAL pull request only requires a single approval to merge labels Feb 26, 2026
@lgeggleston lgeggleston moved this to 🙋 Needs Reviewers Assigned in DSpace 11.0 Release Feb 26, 2026
@lgeggleston lgeggleston moved this to 🙋 Needs Reviewers Assigned in DSpace 10.0 Release Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge bug

Projects

Status: 🙋 Needs Reviewers Assigned

Development

Successfully merging this pull request may close these issues.

Production server clogs the logs on breaking exceptions

3 participants