feat(engine): report failing views with source-mapped stack traces - #708
Draft
romain-pm wants to merge 2 commits into
Draft
feat(engine): report failing views with source-mapped stack traces#708romain-pm wants to merge 2 commits into
romain-pm wants to merge 2 commits into
Conversation
When a view threw, Jahia replaced the fragment with an HTML comment and logged an exception whose JavaScript frames pointed inside the module's bundle (`dist/server/index.js:3937`). Both halves of that are unhelpful: the failure is invisible on the page unless you read the source, and the stack does not say which file you wrote is at fault. The engine now reads the source map the build already emits next to a module's server bundle, and rewrites JS frames back to module sources — `src/components/Foo/default.server.tsx:12`. Maps are parsed on first use and dropped when a module is unregistered, so a redeploy picks up new sources. Frames without a map (the library, the engine itself) are left untouched. In development mode a failing view also renders a visible, HTML-escaped error box in place of its fragment, carrying the message and the mapped stack. In production the exception propagates exactly as before; only the new log line is added. Verified on two Jahia 8.2 instances, one in each mode, against the test module's crashing view: the box appears in development with the frame mapped to TestCrashingView.tsx:11 (the failing line), production output is unchanged, and both modes log the mapped trace. Nine unit tests cover the VLQ decoding, segment lookup and frame rewriting. Closes #700
📝 Documentation GuidelinesThank you for contributing to our documentation! To ensure your contributions meet our standards, please review these resources:
This comment is posted automatically when changes are detected in the |
🦜 Chachalog
|
This was referenced Jul 24, 2026
The class comment claimed production swallows a failing view into an HTML comment while development stays silent. It is the other way around, and neither half was quite right: AbstractFilter#getContentForError emits the comment in both modes — with the message in development, with a timestamp pointing at the logs in production — and a failure landing higher in the render chain propagates as a server error instead. No behaviour change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #700 — part of EPIC #698 (developer experience).
Problem
A view that throws is invisible where a developer looks. Jahia replaces the failed fragment with
<!-- Module error : … -->(AbstractFilter, which includes the message in development mode and hides it in production), so the page still returns 200 and nothing on screen says anything broke. The exception does reach the log, but its JavaScript frames point inside the built bundle:The build already emits a source map next to that bundle. Nothing consumed it.
Change
SourceMaps(new) reads the map shipped next to a module's server bundle, decodes its VLQ mappings, and resolves generated positions back to module sources. Maps are parsed on first use and dropped when the module is unregistered, so a redeploy re-reads them. Frames it cannot map — the library, the engine, Java frames — are left untouched.JSScriptlogs the failure with the mapped stack, and in development mode returns a visible, HTML-escaped error box in place of the fragment. In production it rethrows exactly what it caught: unchanged behaviour, plus the new log line.Frames now read:
Verification
Unit: 9 new tests over VLQ decoding, segment lookup (with and without a column, unmapped lines, out-of-range lines) and frame rewriting —
mvn test -pl javascript-modules-engine-java→ 26 tests, 0 failures.Live, on two Jahia 8.2 instances differing only in operating mode, rendering the test module's existing
testCrashingView:TestCrashingView.tsx:11— the failing lineNotes for the reviewer