feat(runtime): log JSX view-construction errors via sap/base/Log - #11
Closed
petermuessig wants to merge 1 commit into
Closed
petermuessig wants to merge 1 commit into
petermuessig wants to merge 1 commit into
Conversation
Previously, when a JSX view's createContent() threw (sync or async), the error propagated as a rejected Promise but was never written to the UI5 Log. In the showcase it was only rendered as a text control, invisible to log-scraping tooling and sap-ui-log-level debugging. The fix patches View.prototype.onControllerConnected (not createContent, which is bypassed by subclass dynamic dispatch) to install a per-instance wrapper on this.createContent before calling the original method. The wrapper opens the JSX scope (withScope), wraps the subclass call in try/catch plus .catch() for async, calls Log.error on failure, then re-throws — preserving all existing propagation behaviour. The instance own-property is deleted in a finally block so the prototype chain is fully restored after each view construction. ExploreSample.tsx also adds Log.error calls in both its catch handlers (demo-view load failure and docs-load failure) so the exact user-facing message is traceable in the log. Two QUnit regression tests verify both the sync-throw and async-reject paths: Log.error is called exactly once with the right message and component id, and View.create still rejects. Also brings runtime/forwarded-aggregation.qunit.ts from the fix/forwarded-aggregation-issue-9 branch (was missing on main).
Member
Author
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.
Summary
installViewScopeBridge.ts: patchesView.prototype.onControllerConnected(instead ofcreateContent, which subclass dynamic dispatch bypasses) to install a per-instance wrapper onthis.createContent. The wrapper: opens the JSX scope (withScope), callsLog.erroron any sync throw or async rejection, then re-throws/re-rejects so propagation is unchanged. The instance own-property is deleted in afinallyblock.ExploreSample.tsx: addsLog.errorin both catch handlers (demo-view load failure and docs-load failure) so the exact user-facing message is traceable in the UI5 log.runtime/view-error-logging.qunit.ts): two regression tests verify sync-throw and async-reject paths —Log.errorcalled exactly once with the right message/component id, andView.createstill rejects.runtime/forwarded-aggregation.qunit.tsfromfix/forwarded-aggregation-issue-9(was missing onmain; needed for the testsuite entry already added there).Why patch
onControllerConnected, notcreateContentUI5's
onControllerConnectedcallsthis.createContent(e), which dynamically dispatches to the subclass prototype. PatchingView.prototype.createContentonly intercepts code that explicitly callssuper.createContent()— no View subclass does that (the base method is a no-op). By patchingonControllerConnectedinstead, we install a per-instance own-property that shadows both the subclass prototype andView.prototype, so every call path — includingrunWithPreprocessors— routes through our wrapper.Test plan
cd packages/jsx-runtime && npm test— all 12 test modules green (47 total), includingruntime/view-error-logging 🧪 2/2tsc --noEmitclean,eslintclean.changeset/log-view-errors.md(patch bump for@ui5-community/jsx-runtime)