Skip to content

No user-visible loading or error state when README fetch fails#618

Closed
huyhoang171106 wants to merge 1 commit intooffa:masterfrom
huyhoang171106:fix/ui/no-user-visible-loading-or-error-state-w
Closed

No user-visible loading or error state when README fetch fails#618
huyhoang171106 wants to merge 1 commit intooffa:masterfrom
huyhoang171106:fix/ui/no-user-visible-loading-or-error-state-w

Conversation

@huyhoang171106
Copy link
Copy Markdown

Summary

Content is loaded asynchronously from GitHub, but the UI shows a blank page while loading and logs failures only to the console. On slow networks or blocked/CDN-failed requests, users get no feedback and may assume the site is broken.

Files changed

  • index.html (modified)

Testing

  • Not run in this environment.

Closes #617

Signed-off-by: Nguyen Huy Hoang <181364121+huyhoang171106@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 27, 2026 09:38
@huyhoang171106
Copy link
Copy Markdown
Author

Auto-closed: CI checks failed

The following checks failed: Cleanup artifacts

Closing this PR since required CI checks did not pass. Sorry for the inconvenience.

Copy link
Copy Markdown

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

Improves the site’s UX by providing a user-visible loading state and a user-visible error message when the README content cannot be fetched, instead of rendering a blank page and only logging to the console.

Changes:

  • Add an initial loading message to the <main> content area and make it a polite live region.
  • Add HTTP status handling for the README fetch and display a user-facing error message on failure.
  • Refactor DOM updates to target a dedicated #content element.

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

Comment thread index.html
Comment on lines 50 to +53
marked.use( markedGfmHeadingId.gfmHeadingId() );

// Get the markdown file, convert it to HTML & put it inside the main tag
const content = document.getElementById( 'content' );
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The user-visible error state only covers the README fetch. If the jsDelivr scripts fail to load (e.g., markedGfmHeadingId or marked is unavailable), marked.use(...) will throw before the fetch chain runs, leaving the page stuck on the loading message with no visible error. Consider guarding these globals (or wrapping the marked setup in a try/catch) and updating content with a user-facing failure message in that case too.

Suggested change
marked.use( markedGfmHeadingId.gfmHeadingId() );
// Get the markdown file, convert it to HTML & put it inside the main tag
const content = document.getElementById( 'content' );
const content = document.getElementById( 'content' );
try
{
if( typeof marked === 'undefined'
|| typeof markedGfmHeadingId === 'undefined'
|| typeof marked.use !== 'function' )
{
throw new Error( 'Markdown renderer not available' );
}
marked.use( markedGfmHeadingId.gfmHeadingId() );
}
catch( error )
{
if( content )
{
content.innerHTML = '<p>Unable to load content right now. Please retry later.</p>';
}
console.error( 'Error initializing markdown renderer:', error );
// Do not proceed to fetch README if we cannot render it
return;
}
// Get the markdown file, convert it to HTML & put it inside the main tag

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.

fix: no user-visible loading or error state when readme fetch fails

2 participants