[Fastify-Adapter] Injecting @Res() results in timeout of endpoint
See original GitHub issueBug Report
Current behavior
When using Fastify-Adapter
and then injecting fastify response via @Res() decorator in controller method results in timeout of that endpoint (even when sending a response via res.send(...)
)
Input Code
https://github.com/mschuttt/bug-nest-fastify-adapter
nest new bug-fastify
remove @nestjs/platform-express
from package.json
npm i --save @nestjs/platform-fastify
change main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { NestFastifyApplication, FastifyAdapter } from '@nestjs/platform-fastify';
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
await app.listen(3000);
}
bootstrap();
change app.controller.ts
import { Controller, Get, Res } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(@Res() res): void {
res.send('hello')
}
}
npm run start
browser or postman: localhost:3000
<- endpoint times out… no response!
(refer to git repo above…)
Expected behavior
When sending a response (res.send(...)
) - endpoint should send a response!
Environment
Nest version: 6.8.2
For Tooling issues:
- Node version: v10.15.3
- Platform: Linux Ubuntu 16.04
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
NestJS - Increase response timeout for particular http endpoint
I have tried to increase timeout on endpoint using interceptors like: import { Injectable, NestInterceptor, ExecutionContext, CallHandler, ...
Read more >nest - Bountysource
For a better monitoring of my Nest microservices I'd like to have a metrics endpoint which can be scraped by monitoring systems like...
Read more >Task Scheduling | NestJS - A progressive Node.js framework
The .forRoot() call initializes the scheduler and registers any declarative cron jobs, timeouts and intervals that exist within your app. Registration occurs ...
Read more >技术
@Injectable() export class UsersService { constructor(private connection: ... 此外,注入本机响应对象( @Res() )的 HTTP 服务器路由不能使用缓存拦截器。
Read more >Laska_bakalvr.pdf - КПІ
Таблиці «migration» та «query-result-cache» є службовими таблицями, ... В його основі лежить принцип Dependency Injection (Впровадження.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Could you check out my provided sample repo, please? The example provided under
sample
(10-fastify
) doesn’t` work for me neither when I add an endpoint with the @Res() decoratorMy sample endpoint in cats controller
the only way I get it to work is to downgrade the @nestjs packages
This is only an issue with 6.8.2
Fixed in 6.8.3. Please, let me know if you face any issue.