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

feat(platform-fastify): added support for Fastify v5 #13990

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

Tony133
Copy link
Contributor

@Tony133 Tony133 commented Sep 17, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Proposal:

  • Added compatibility for Fastify version 5.x 🔥

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

It would be nice if NestJS version 10.x was already compatible with Fastify v5.x without waiting for the next major version of NestJS, leaving compatibility with Fastify v4.x

@Tony133 Tony133 force-pushed the feat/upgrade-fastify-v5 branch from 277ea4b to 581e13d Compare September 17, 2024 20:36
@coveralls
Copy link

coveralls commented Sep 17, 2024

Pull Request Test Coverage Report for Build 43f02eb1-91a6-4a9f-95c4-f78a85742b67

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.243%

Totals Coverage Status
Change from base Build 72f148bc-4145-44b3-a3c4-06a616307114: 0.0%
Covered Lines: 6754
Relevant Lines: 7322

💛 - Coveralls

@Tony133 Tony133 changed the title feat: upgrade fastify v5.x feat: added compatibility for Fastify version 5.x 🔥 Sep 17, 2024
@Tony133 Tony133 changed the title feat: added compatibility for Fastify version 5.x 🔥 feat: added compatibility for fastify version 5.x 🔥 Sep 17, 2024
@Tony133 Tony133 changed the title feat: added compatibility for fastify version 5.x 🔥 feat(platform-fastify): added compatibility for fastify version 5.x 🔥 Sep 17, 2024
@Tony133 Tony133 force-pushed the feat/upgrade-fastify-v5 branch from 581e13d to 0acb84c Compare September 17, 2024 20:57
@kamilmysliwiec
Copy link
Member

Fastify v5 requires Node v20 so we will have to wait till the next major release of Nest to make the version bump.

@micalevisk
Copy link
Member

@johaven please open a new feature request issue for that instead.

@songkeys
Copy link

Fastify v5 requires Node v20 so we will have to wait till the next major release of Nest to make the version bump.

If it's compatible with both v4 and v5, I don't think it's necessary to wait for the next major of Nest?

@zackdotcomputer
Copy link

Agreed with @songkeys - since this is just expanding support to include Fastify 5, and not dropping support for earlier versions either of fastify or of node itself, it feels like it could be included in a minor version update?

@SzymonGonet
Copy link

SzymonGonet commented Oct 10, 2024

@kamilmysliwiec I guess there’s no need to wait for the next major release - if possible, it’d be great if you could go ahead and merge it.

@micalevisk
Copy link
Member

micalevisk commented Oct 14, 2024

The thing is that: NestJS v10 is supposed to support nodejs v16. Thus, changing those semver ranges of dependencies list will break this support because Fastify v5 only supports Node.js v20+. So running npm i @nestjs/platform-fastify (without having fastify in your deps list) will install fastify@5 alongside. And you won't see anything wrong after installing it because fastify don't have the engines.node attribute on their package.json.

I know that if you have fastify@4 in your dependencies list already, the v5 one won't be installed upon installing @nestjs/platform-fastify

Not sure how we could address this limitation(?) without a major bump on NestJS side.

@zackdotcomputer
Copy link

Ah - that makes sense @micalevisk. I actually ran into that issue with a different package recently so understand what you mean. One possibility for future-proofing this would be to move fastify to be a peer dependency, so that end-developers manage the version of fastify they're using directly? That sort of change would also definitely need to be done in a major version bump, though.

I guess, given that, what are the possibilities of doing a major version bump for the nestjs + fastify package specifically? Or is the philosophy here that this package's version needs to stay in sync with the mainline nestjs?

@micalevisk micalevisk mentioned this pull request Oct 16, 2024
1 task
@PattyTrish
Copy link
Contributor

I'd like to see if we could have a major version in the works to support both Fastify v5 and Express v5, since these have both just come out recently.

Due to the version ambiguity @micalevisk mentioned, I think a major version update is the way to go, FWIW. Is there ongoing work/planning for this? The packages here all leave LTS next year: it needs to happen at some point.

@gperdomor
Copy link
Contributor

The thing is that: NestJS v10 is supposed to support nodejs v16. Thus, changing those semver ranges of dependencies list will break this support because Fastify v5 only supports Node.js v20+. So running npm i @nestjs/platform-fastify (without having fastify in your deps list) will install fastify@5 alongside. And you won't see anything wrong after installing it because fastify don't have the engines.node attribute on their package.json.

I know that if you have fastify@4 in your dependencies list already, the v5 one won't be installed upon installing @nestjs/platform-fastify

Not sure how we could address this limitation(?) without a major bump on NestJS side.

In any case, Node 16 reach end of life1 year ago, and Node 18 will do the same in 6 months, so I think that release a new major release with Node 20 as breaking change is more that justified...

Copy link

@CarsonF CarsonF left a comment

Choose a reason for hiding this comment

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

FastifyReply added RouteGeneric before the RawServer generic (following suit of FastifyRequest).
This needs to be accounted for in the adapter.
https://github.com/nestjs/nest/blob/master/packages/platform-fastify/adapters/fastify-adapter.ts#L131-L132

Also the path-to-regexp v6 -> v8 is breaking the path normalization in the middleware.
https://github.com/nestjs/nest/blob/master/packages/platform-fastify/adapters/fastify-adapter.ts#L584-L600

@gperdomor
Copy link
Contributor

Any progress here?... :(

@micalevisk
Copy link
Member

@gperdomor the support for Fastify v5 will be add in NestJS v11. There is no ETA.

@Tony133 Tony133 force-pushed the feat/upgrade-fastify-v5 branch from efcd4c1 to 7de7320 Compare November 7, 2024 17:38
@Tony133
Copy link
Contributor Author

Tony133 commented Nov 7, 2024

Hi 👋🏻, I have updated the PR is ready to merge for the future version 11 of NestJS, I have also updated the fastify dependency to v5.1.0 🔥 and other dependencies.

@Tony133 Tony133 changed the base branch from master to 11.0.0 November 13, 2024 07:50
@kamilmysliwiec kamilmysliwiec added dependencies Pull requests that update a dependency file scope: platform labels Nov 18, 2024
@kamilmysliwiec kamilmysliwiec added this to the 11.0.0 milestone Nov 18, 2024
@kamilmysliwiec kamilmysliwiec changed the title feat(platform-fastify): added compatibility for fastify version 5.x 🔥 feat(platform-fastify): added support for Fastify v5 Nov 18, 2024
@kamilmysliwiec kamilmysliwiec merged commit fb6025e into nestjs:11.0.0 Nov 18, 2024
5 checks passed
@kamilmysliwiec kamilmysliwiec mentioned this pull request Nov 20, 2024
12 tasks
@0x0bit
Copy link

0x0bit commented Dec 11, 2024

When will this be released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file scope: platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.