Skip to content

ApplicationHooks have inconsistent reference to instance #4967

@Uzlopak

Description

@Uzlopak

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

While looking at the onListen hook PR, I realized it is not that strict on how the application hooks refer to the instance.

  • onRoute has the reference to the instance in the this parameter
  • onRegister has the reference to the instance in the instance parameter
  • onClose has the reference to the instance in the instance parameter
  • onReady has the reference to the instance in the this reference
  • onListen has the reference to the instance in the this parameter
  • preClose has the reference to the instance in the this reference

I dont see any pattern.

### Tasks
- [ ] https://github.com/fastify/fastify/pull/4972
- [ ] Document the this context more clearly for every hook

How to implement it:

We choose to convert the parameters into an object and bind the this context too:

#4967 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature to be addedgood first issueGood for newcomersnotable-changeA change that should be explicitly outlined in release notes and migration guidesv5.xIssue or pr related to Fastify v5

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions