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(cli): use user-defined error hook #165

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

markthree
Copy link
Contributor

πŸ”— Linked issue

unjs/h3#695

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

We should use the user-defined onError hook

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@@ -149,6 +149,10 @@ export async function createDevServer(
_loadedEntry.default ||
_loadedEntry;

if (_handler.options && _handler.options.onError) {
app.options.onError = _handler.options.onError;
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking we could inherit/merge all options. For example for this unjs/h3#693 (and debug option)

Copy link
Contributor Author

@markthree markthree Mar 7, 2024

Choose a reason for hiding this comment

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

Of course this would be better, but I've tested how to do the merge and some of the hooks trigger twice

for example ↓

if (_handler.options) {
  // This causes some hooks to run twice
  app.options = Object.assign(app.options, _handler.options)
}

I think this might be a bug in h3, and I think I'd have to look deeper at h3 as well.

I like unjs/h3#693,But I'd like to see the logic of your implementation, let's try to keep the behavior consistent πŸ₯°

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.

None yet

2 participants