Skip to content

fix: guard dynamic import transient errors - #901

Open
maxakuru wants to merge 1 commit into
mainfrom
fix/fragment-import-guard
Open

maxakuru wants to merge 1 commit into
mainfrom
fix/fragment-import-guard

Conversation

@maxakuru

@maxakuru maxakuru commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Problem

Several lazy features are pulled in with a dynamic import(...).then(...) that has no rejection handler. A dynamic import can reject at the network level with:

TypeError: Failed to fetch dynamically imported module: https://www.vitamix.com/blocks/fragment/fragment.js

on a transient failure (offline, connection reset, or a request blocked by an extension). With no handler, that rejection becomes an unhandled promise rejection and surfaces in monitoring. Note that a surrounding synchronous try/catch does not catch it, since the failure is async.

Fix

Guard the three unhandled dynamic imports in scripts.js so a failed module fetch degrades gracefully instead of throwing an unhandled rejection:

  • fragment auto-block — fragment links are left in place; the failure is logged to the console (matching the existing per-fragment error handling right beside it).
  • image color extraction — the image keeps its default color treatment.
  • gift-with-purchase — stays uninitialized for this page load and resumes on the next navigation.

Each uses the two-argument .then(onFulfilled, onRejected) form, so only the import rejection is handled — a genuine error thrown inside the fulfilled callback still propagates and stays visible.

Test URLs

To reproduce: load a page that uses one of these features (e.g. a page with a fragment reference) and cause the module request to fail at the network level (offline, or blocked by an extension). Before the fix this throws an unhandled rejection; after the fix the feature degrades quietly and the page stays healthy.

🤖 Generated with Claude Code

@aem-code-sync

aem-code-sync Bot commented Sep 11, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run all PSI checks
  • Re-run failed PSI checks
  • Re-sync branch
Commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant