Skip to content
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

FIX: throw error when local iconDir fails to load #259

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

madcampos
Copy link

@madcampos madcampos commented Dec 18, 2024

When iconDir doesn't exist. Any changes made to files will stop working due to how the code is set to call moduleGraph.invalidateAll() only after all icons are loaded.

This change adds an error message that the local collection has failed to load.

Resolves: #260

Copy link

changeset-bot bot commented Dec 18, 2024

⚠️ No Changeset found

Latest commit: d21c415

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Dec 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-astroicon ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2024 6:00am
astroicon ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2024 6:00am

@@ -62,6 +62,7 @@ export function createPlugin(
moduleGraph.invalidateAll();
} catch (ex) {
// Failed to load the local collection
throw new Error(`Failed to load local collection at: ${iconDir}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this throw or should this remove the local collection then invalidate?

Copy link
Author

@madcampos madcampos Dec 27, 2024

Choose a reason for hiding this comment

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

If an error is thrown, it breaks the whole server, effectively stopping everything from running until the configuration is reloaded.

Here are a couple of options:

  • Report the error and continue
  • Silently create the folder and continue
  • Throw an error and stop the server until the error is fixed

The first two options resolve the issue, but trying to load a local icon will just break everything afterwards as the file will not exist.

Creating the folder may give a slightly better experience though.

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.

When iconsDir doesn't exist, live reload silently fails
2 participants