-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: better cdn failure messaging. #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -189,6 +189,28 @@ test('BYOT controls stay hidden when feature flag is disabled', async ({ page }) | |||||
| await expect(page.locator('#ai-chat-drawer')).toBeHidden() | ||||||
| }) | ||||||
|
|
||||||
| test('shows actionable status when core CDN dependency loading fails', async ({ | ||||||
| page, | ||||||
| }) => { | ||||||
| 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 waitForAppReady(page) | ||||||
| await expect(page.locator('#status')).toHaveText( | ||||||
| 'Error loading CDN dependency. Reload to retry.', | ||||||
| ) | ||||||
| await expect(page.locator('#preview-host')).toContainText( | ||||||
|
||||||
| await expect(page.locator('#preview-host')).toContainText( | |
| await expect(page.locator('#preview-host pre')).toContainText( |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -815,11 +815,21 @@ export const createRenderRuntimeController = ({ | |
| setStatus('Rendered', 'neutral') | ||
| setRenderedStatus() | ||
| } catch (error) { | ||
| setStatus('Error', 'error') | ||
| const errorMessage = error instanceof Error ? error.message : String(error) | ||
| const isCdnDependencyLoadFailure = errorMessage.startsWith( | ||
| 'Unable to load core runtime from CDN:', | ||
| ) | ||
knightedcodemonkey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| setStatus( | ||
| isCdnDependencyLoadFailure | ||
| ? 'Error loading CDN dependency. Reload to retry.' | ||
| : 'Error', | ||
|
Comment on lines
+819
to
+826
|
||
| 'error', | ||
| ) | ||
| const target = getRenderTarget() | ||
| clearTarget(target) | ||
| const message = document.createElement('pre') | ||
| message.textContent = error instanceof Error ? error.message : String(error) | ||
| message.textContent = errorMessage | ||
| message.style.color = '#ff9aa2' | ||
| target.append(message) | ||
| } finally { | ||
|
|
||
There was a problem hiding this comment.
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.