Skip to content

refactor: better cdn failure messaging.#28

Closed
knightedcodemonkey wants to merge 1 commit intomainfrom
bananas
Closed

refactor: better cdn failure messaging.#28
knightedcodemonkey wants to merge 1 commit intomainfrom
bananas

Conversation

@knightedcodemonkey
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings March 22, 2026 17:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the runtime render error UX by surfacing a more actionable status message when a core runtime CDN import fails, and adds an E2E test to prevent regressions.

Changes:

  • Detect core runtime CDN load failures during preview render and set a more actionable status message.
  • Add a Playwright test that simulates failed @knighted/* CDN loads and asserts the new status/error output.
  • Remove the “CDN failure recovery UX” item from docs/next-steps.md and renumber the remaining items.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/modules/render-runtime.js Adds error classification for core runtime CDN load failures and sets a more actionable status message.
playwright/app.spec.ts Adds E2E coverage for the new actionable status when core CDN imports fail.
docs/next-steps.md Updates the roadmap by removing the CDN recovery UX item and renumbering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +819 to +826
const isCdnDependencyLoadFailure = errorMessage.startsWith(
'Unable to load core runtime from CDN:',
)

setStatus(
isCdnDependencyLoadFailure
? 'Error loading CDN dependency. Reload to retry.'
: 'Error',
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isCdnDependencyLoadFailure is currently true only for core runtime CDN failures. Since this file can also throw Unable to load React runtime from CDN: ... (and other CDN-backed imports exist), the name is misleading and the status UX will remain generic for other CDN dependency failures. Either broaden the detection to cover the other Unable to load ... from CDN: cases, or rename the variable/message to explicitly reference core runtime loading.

Copilot uses AI. Check for mistakes.
Comment on lines +195 to +204
await page.route('**/*', async route => {
const url = route.request().url()

if (url.includes('@knighted') || url.includes('%40knighted')) {
await route.abort()
return
}

await route.continue()
})
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test routes all requests via page.route('**/*', ...), which is heavier than necessary and can introduce flakiness by accidentally affecting unrelated resources. Consider narrowing the route pattern to only CDN requests for the core runtime packages (e.g., the esm.sh/unpkg/jspm URLs for @knighted/*) so navigation + local assets aren’t intercepted.

Suggested change
await page.route('**/*', async route => {
const url = route.request().url()
if (url.includes('@knighted') || url.includes('%40knighted')) {
await route.abort()
return
}
await route.continue()
})
await page.route(
url => url.includes('@knighted') || url.includes('%40knighted'),
async route => {
await route.abort()
},
)

Copilot uses AI. Check for mistakes.
await expect(page.locator('#status')).toHaveText(
'Error loading CDN dependency. Reload to retry.',
)
await expect(page.locator('#preview-host')).toContainText(
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with other error-state assertions in this suite (and to avoid any ShadowRoot/text-aggregation quirks), assert against the rendered error element itself (e.g., #preview-host pre) instead of #preview-host when checking for the runtime load failure message.

Suggested change
await expect(page.locator('#preview-host')).toContainText(
await expect(page.locator('#preview-host pre')).toContainText(

Copilot uses AI. Check for mistakes.
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.

2 participants