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.

[Fastify-Adapter] Injecting @Res() results in timeout of endpoint

See original GitHub issue

Bug 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
mschutttcommented, Oct 9, 2019

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() decorator

My sample endpoint in cats controller

  @Get('testo')
  hello(@Res() res) {
    res.send('hallo')
  }

the only way I get it to work is to downgrade the @nestjs packages

@nestjs/common @nestjs/core @nestjs/platform-fastify Response
6.8.2 6.8.2 6.8.2 No
6.7.2 6.7.2 6.7.2 Yes

This is only an issue with 6.8.2

1reaction
kamilmysliwieccommented, Oct 10, 2019

Fixed in 6.8.3. Please, let me know if you face any issue.

Read more comments on GitHub >

github_iconTop 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 >

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