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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/server/dev.ts
Expand Up @@ -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 πŸ₯°

}

if (options.ws) {
Object.assign(
dynamicWS,
Expand Down