Fix white screen issue when loading category pages directly - #34
Draft
therealpaulgg with Copilot wants to merge 3 commits into
Draft
Fix white screen issue when loading category pages directly#34therealpaulgg with Copilot wants to merge 3 commits into
therealpaulgg with Copilot wants to merge 3 commits into
Conversation
Co-authored-by: therealpaulgg <21159486+therealpaulgg@users.noreply.github.com>
Co-authored-by: therealpaulgg <21159486+therealpaulgg@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] White screen when loading category page
Fix white screen issue when loading category pages directly
Jun 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the white screen issue that occurs when users navigate directly to a category page (e.g.,
/category/cooking) instead of navigating from the home page.Problem
When loading a category page directly, users would see a white screen due to unhandled errors in the data loading process. The issue only occurred on direct navigation - navigating from the home page worked correctly.
Root Cause
The issue was caused by lack of error handling in two critical places:
src/routes/category/[slug].json/+server.ts): No error handling for file system operations or markdown processing failuressrc/routes/category/[slug]/+page.ts): No error handling for fetch request failuresAny errors during data loading would cause the entire page load to fail, resulting in a white screen instead of graceful fallback behavior.
Solution
Added comprehensive error handling to both components:
Server Endpoint Changes
[]as fallback when category directory doesn't exist or can't be readPage Loader Changes
{ recipes: [], slug }as fallback when API request failsTesting
The fix ensures that category pages always load gracefully, even when there are underlying data issues, while maintaining full functionality for valid categories.
Fixes #33.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.