- Issue created by @lauriii
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
We don't need to improve error handling. We need to figure out how this is possible, given:
### 3.1 `SDC` `component`s #### 3.1.1 Criteria for `SDC` `component`s For an `SDC` to be compatible/eligible for use in XB, it: … - MUST have `example` for each required prop …
👆 This means it should be impossible for the error in the screenshot to ever occur.
Which SDC did this happen for?
- 🇫🇮Finland lauriii Finland
This is not an issue to fix the specific error. I opened 🐛 PHP warning on image props without examples Active 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.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Fair. But the title is super vague/misleading then. Fixed.
- 🇫🇮Finland lauriii Finland
This 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.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
#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:
- sort of https://git.drupalcode.org/project/acquia_migrate/-/commit/238a173d454ee...
- sort of https://git.drupalcode.org/project/acquia_migrate/-/commit/eb881eb8101bb...
- but especially https://git.drupalcode.org/project/acquia_migrate/-/commit/7931c1f843be9...
We should do a combination of both catching
\Exception
(i.e. ALL exceptions) and using PHP's low-levelset_error_handler()
inApiComponentsController
andApiPreviewController
(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? 😊
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Comments 11 through 19 of 📌 Preview entire page not just content area Active are AFAICT essentially re-hashing this issue 😅😬
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Also 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
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
- Assigned to larowlan
- Status changed to Needs review
4 months ago 3:33pm 8 January 2025 - 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
This blocks #3502769, see #3502769-4: [PP-2] auto-saved PageRegions may be invalid, but MUST NOT cause XB's previews to fail. → .
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Note 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.
- Issue was unassigned.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
📌 Recover from server-side errors that may happen during rendering preview Active already hardened the client side 🤘
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Updating issue title to convey to everyone this bit from the issue summary:
js
: SHOULD NOT be possible to happen for "code components" — but actually can if there's a JS error dependent on the input ⚠️ If this turns out to be too difficult to do as part of this issue, this portion can be descoped to a follow-up issue.
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 → .
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
#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 📌 [PP-1] Failing kernel tests for all ways a component source can fail to render on the server side Active introduced, plus add the necessary infrastructure.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Given the additions to
/xb/api/layout/…
responses, this will need to updateopenapi.yml
. - 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Reflecting that 📌 [PP-1] Failing kernel tests for all ways a component source can fail to render on the server side Active is itself also blocked.
And added more detail about how to imoplement this.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Reflecting that 📌 [PP-1] Failing kernel tests for all ways a component source can fail to render on the server side Active is itself also blocked.
And added more detail about how to imoplement this.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Extracted the exposing to the client to 📌 [PP-3] Server-rendered component instances failing to render should expose the meaningful error to the XB UI in a structured way Postponed .
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Working on this on top of 📌 [PP-1] Failing kernel tests for all ways a component source can fail to render on the server side Active
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
- Merge request !933Issue #3485878: Server-rendered component instances should NEVER result in a user-facing error → (Open) created by wim leers
- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Showing 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.