Skip to content

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

Closed
JorgeEscire wants to merge 1 commit into
DSpace:mainfrom
JorgeEscire:Issue/4124
Closed

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

Conversation

@JorgeEscire

Copy link
Copy Markdown

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.

@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
@alegontarz

Copy link
Copy Markdown

QA testing performed (no code review).

Works as expected:

  1. After adding a test error in server.ts and running a production SSR build, the stack trace points to readable line numbers in dist/server/main.js instead of a single minified line.

@alegontarz alegontarz moved this from 🙋 Needs Reviewers Assigned to 👀 Under Review in DSpace 10.0 Release Mar 12, 2026
@tdonohue tdonohue moved this from 👀 Under Review to 👍 Reviewer Approved in DSpace 10.0 Release Mar 13, 2026
@tinsch

tinsch commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

⚠️ @JorgeEscire @oscar-escire please take a look, this PR seems to be affected by the malicious bot code you mentioned in another PR.

@tdonohue

Copy link
Copy Markdown
Member

Closing, as this PR is impacted by PolinRider malware.

⚠️ DO NOT DOWNLOAD OR RUN THIS PR until the attack code is removed.

@JorgeEscire and @oscar-escire : We can reopen this PR once it is cleaned up.

@tdonohue tdonohue closed this Mar 30, 2026
@github-project-automation github-project-automation Bot moved this from 👍 Reviewer Approved to ✅ Done in DSpace 10.0 Release Mar 30, 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

None yet

Development

Successfully merging this pull request may close these issues.

Production server clogs the logs on breaking exceptions

6 participants