Closed (fixed)
Project:
Experience Builder
Version:
0.x-dev
Component:
Component sources
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 Nov 2024 at 12:44 UTC
Updated:
18 Jun 2025 at 22:16 UTC
Jump to comment: Most recent, Most recent file


Comments
Comment #2
lauriiiComment #3
wim leersWe don't need to improve error handling. We need to figure out how this is possible, given:
👆 This means it should be impossible for the error in the screenshot to ever occur.
Which SDC did this happen for?
Comment #4
lauriiiThis is not an issue to fix the specific error. I opened #3485427: PHP warning on image props without examples for that. This issue is to improve the error handling, because I would not expect PHP errors from the small preview iframes to render in the preview canvas. I also would not expect errors to render inside the small preview iframes.
Comment #5
wim leersFair. But the title is super vague/misleading then. Fixed.
Comment #6
lauriiiThis is not so much about rendering PHP errors vs not. This was about where and how those errors should be rendered. For example, the error in the issue summary, is not even something that happens as part of the preview request, it happens on the component preview request. We should improve the error handling so that errors that happen during API requests, never end up in the preview.
Comment #7
wim leers#6: Yep, that's how I interpreted #4, and what I captured in the updated issue title? 😅
That kind of super broad exception+error catching is something that I've seen only happen in "Drupal userland" one other time: in https://www.drupal.org/project/acquia_migrate, see:
We should do a combination of both catching
\Exception(i.e. ALL exceptions) and using PHP's low-levelset_error_handler()inApiComponentsControllerandApiPreviewController(probably actually in the code that they call) — those two combined would be able to achieve what you describe, @lauriii 😊Issue summary updated with outline of implementation based on your feedback.
WDYT? 😊
Comment #8
wim leersComment #9
lauriiiProposal makes sense. Thank you @wim leers! 💯
Comment #10
wim leersComments 11 through 19 of #3489302: Preview entire page not just content area are AFAICT essentially re-hashing this issue 😅😬
Comment #11
larowlanAlso FWIW I've seen errors break the whole page when using the auto-save controller and pushing invalid data - because SDC has a twig function to validate the component and that throws a RuntimeError that is uncaught.
I had a workaround in an earlier version of https://git.drupalcode.org/project/experience_builder/-/merge_requests/430 that turned this off so at least one invalid component didn't break the whole preview.
We may need to revive that here
Comment #12
wim leers#11: Curious what you think about the detailed plan I wrote up in #7. What you describe works for SDCs, but won't work for arbitrary component types, whereas #7 would.
Comment #13
wim leersComment #14
wim leersThis blocks #3502769, see #3502769-4: Auto-saved PageRegions may be invalid, but MUST NOT cause XB's previews to fail..
Comment #15
wim leersNote that if we make this also handle JS errors, that a whole class of "oops, application crashed" problems would be guaranteed to be protected against.
Comment #16
wim leersComment #17
jessebaker commentedComment #18
wim leers#3511888: Recover from server-side errors that may happen during rendering preview already hardened the client side 🤘
Comment #19
wim leersStill would like @larowlan's input — accidentally unassigned in #15.
Comment #20
wim leersComment #21
wim leersUpdating issue title to convey to everyone this bit from the issue summary:
AFAICT solving the intent of this issue for code components can only be achieved by wrapping each code component in some XB-owned wrapper that catches these problems. See my related comment at #3499919-22: [Meta] Plan for in-browser code components.
Comment #22
wim leers#21: @effulgentsia is confident about
<astro-island>'s ability to handle most of this for us, and is confident we’ll be able to still intercept the error and render a nice fallback of our own design/choosing.That means this issue can focus solely on the server-side aspects, which basically means making all the failing tests that #3517966: Failing kernel tests for all ways a component source can fail to render on the server side introduced, plus add the necessary infrastructure.
Comment #23
wim leersGiven the additions to
/xb/api/layout/…responses, this will need to updateopenapi.yml.Comment #24
wim leersReflecting that #3517966: Failing kernel tests for all ways a component source can fail to render on the server side is itself also blocked.
And added more detail about how to imoplement this.
Comment #25
wim leersReflecting that #3517966: Failing kernel tests for all ways a component source can fail to render on the server side is itself also blocked.
And added more detail about how to imoplement this.
Comment #26
wim leersExtracted the exposing to the client to #3518201: Server-rendered component instances failing to render should expose the meaningful error to the XB UI in a structured way.
Comment #27
wim leersComment #28
nagwani commentedComment #29
wim leersComment #30
larowlanWorking on this on top of #3517966: Failing kernel tests for all ways a component source can fail to render on the server side
Comment #31
wim leers#3517966: Failing kernel tests for all ways a component source can fail to render on the server side is in!
Comment #32
wim leersRebased 👍
Comment #34
larowlanShowing it in action 😎
I changed the cta1 prop to be required and this broke an existing component.
I could still update the component props and then it rendered fine again.
Comment #35
larowlanComment #36
larowlanLog entry
Comment #37
larowlanComment #38
larowlanOnly remaining fail is a known issue in HEAD
Comment #39
wim leersComment #40
wim leersThis MR looks great! I posted some Qs on the MR.
The only things I'm missing:
set_error_handler()+restore_error_handler(). (I realize now that #3517966: Failing kernel tests for all ways a component source can fail to render on the server side did not add explicit test coverage for that.) But … perhaps that's just not really worth it? Because this MR is catching\Throwableinstead of\Exception, which means the actually risky subset of errors is already handled?isPreview: FALSE|TRUE, because we'll need that per [#3517941].Keeping at for @longwave's review — but I'm excited this looks so close! 😄
Comment #41
larowlanAddressed all the feedback. Left one item open to discuss an alternate approach. I think the current approach is scoped to just our neck of the woods and feel the alternate approach (decorating the renderer) would probably be overreach.
Comment #42
wim leersI'd like @longwave to do the final review here, but this looks great to me 😊
(Let's also add 2 screenshots to the issue summary, one for a crashing component with
isPreview: FALSE, one forisPreview: TRUE.)Comment #43
larowlanAdded screenaroonies
Comment #44
longwaveAdded some questions/feedback.
Comment #45
longwaveComment #46
longwaveFixed all my own feedback except for the plugin ID and the user-facing error message, back to RTBC.
Comment #47
larowlanComment #48
wim leersYep, for the user-facing error message, see the parent meta!
Once designers can see this in action (thanks for the screenshots, Lee!), this is much easier to design for 😊
Comment #50
wim leersHUGE leap forward for XB’s robustness! 🥳
Thank you all for the excellent work on this one! 😊 👏
Comment #52
effulgentsia commented