Skip to content

fix(app): update event before calling request hook#3155

Merged
pi0 merged 3 commits intonitrojs:v2from
zsilbi:fix/event-context
Mar 5, 2025
Merged

fix(app): update event before calling request hook#3155
pi0 merged 3 commits intonitrojs:v2from
zsilbi:fix/event-context

Conversation

@zsilbi
Copy link
Contributor

@zsilbi zsilbi commented Mar 5, 2025

🔗 Linked issue

Fixes #3150

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)

📚 Description

event.context.nitro is currently initialized in the generic event handler of h3App.
The request hook is called in h3App.onRequest() which runs before the generic event handler.
By moving the nitro context initialization there, we can also provide the context for the listeners of the request hook.

📝 Checklist

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

@zsilbi zsilbi requested a review from pi0 as a code owner March 5, 2025 11:53
@pi0 pi0 changed the title fix(app): initialize event.context.nitro before calling request hook fix(app): populate event before calling request hook Mar 5, 2025
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks, onRequest was added later we could move other init logic early here as well!

@pi0 pi0 changed the title fix(app): populate event before calling request hook fix(app): update event before calling request hook Mar 5, 2025
@pi0 pi0 merged commit c9d1032 into nitrojs:v2 Mar 5, 2025
4 checks passed
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.

useRuntimeConfig(event) never return inside "request" nitro hook

2 participants