question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Non-functionnal API versioning with Fastify + MediaType

See original GitHub issue

Bug Report

Current behavior

Fastify

If I configure to use Fastify-platform, the server initialize without any problem, but does not start nor open the listening socket, even if the callback at api.listen returns a value.

[Nest] 35105  - 08/15/2021, 12:22:04 PM     LOG [NestFactory] Starting Nest application...
[Nest] 35105  - 08/15/2021, 12:22:04 PM     LOG [InstanceLoader] AppModule dependencies initialized +38ms
[Nest] 35105  - 08/15/2021, 12:22:04 PM     LOG [RoutesResolver] AppController {/}: +7ms
[Nest] 35105  - 08/15/2021, 12:22:04 PM     LOG [RouterExplorer] Mapped {/, GET} (version: 1) route +3ms
[Nest] 35105  - 08/15/2021, 12:22:04 PM     LOG [RouterExplorer] Mapped {/, GET} (version: 2) route +0ms
[Nest] 35105  - 08/15/2021, 12:22:04 PM     LOG [NestApplication] Nest application successfully started +3ms
Displayed: Running at http://127.0.0.1:3000/

<<< END OF THE INPUT

The server never open the listening socket

Express

This is working with Express-platform.

[Nest] 35139  - 08/15/2021, 12:23:25 PM     LOG [NestFactory] Starting Nest application...
[Nest] 35139  - 08/15/2021, 12:23:25 PM     LOG [InstanceLoader] AppModule dependencies initialized +35ms
[Nest] 35139  - 08/15/2021, 12:23:25 PM     LOG [RoutesResolver] AppController {/}: +7ms
[Nest] 35139  - 08/15/2021, 12:23:25 PM     LOG [RouterExplorer] Mapped {/, GET} (version: 1) route +4ms
[Nest] 35139  - 08/15/2021, 12:23:25 PM     LOG [RouterExplorer] Mapped {/, GET} (version: 2) route +1ms
[Nest] 35139  - 08/15/2021, 12:23:25 PM     LOG [NestApplication] Nest application successfully started +2ms
Displayed: Running at http://127.0.0.1:3000/
Not displayed: Running at http://[::1]:3000

<<< END OF THE INPUT

Input Code

I made a simple POC to illustrate the problem:

https://github.com/lolo32/poc-nest-swagger-versioning-error/tree/error-fastify

Expected behavior

Using Fastify must works like Express does.

Environment

 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/


[System Information]
OS Version     : macOS Catalina
NodeJS Version : v14.17.4
NPM Version    : 7.20.5 

[Nest CLI]
Nest CLI Version : 8.1.1 

[Nest Platform Information]
platform-express version : 8.0.6
platform-fastify version : 8.0.6
schematics version       : 8.0.2
testing version          : 8.0.6
common version           : 8.0.6
core version             : 8.0.6
cli version              : 8.1.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
micaleviskcommented, Aug 15, 2021

my bad. I didn’t notice the versioning

it’s possible to have more than one @Get() route it has different version.

And this bug appears due do that, I’ve tested

0reactions
kamilmysliwieccommented, Aug 17, 2021

Thanks for your research @micalevisk! I’ve created a Draft PR here https://github.com/nestjs/nest/pull/7874 let’s move the discussion there

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nestjs versioning configuration when using Fastify
For performance reasons of a relatively complex Nestjs application, we have chosen to use Fastify as our HTTP provider.
Read more >
Ecosystem - Fastify
Fast and low overhead web framework, for Node.js.
Read more >
fastify-api - npm
A radically simple API routing and method injection library for Fastify. Latest version: 0.2.0, last published: 2 years ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found