L
L
lightseeker2021-09-18 21:31:56
Node.js
lightseeker, 2021-09-18 21:31:56

Why does thread block execution?

here is a code snippet. with multiple parallel requests, they are executed alternately every 5 seconds

@Controller('request')
export class HOController {
  constructor() {}

  @SkipAuth()
  @All('/')
  @UseGuards(ApiKeyGuard)
  async index(@Request() req, @Res() res) {
    console.log('--- REQUEST RECEIVED ---');
    await new Promise((res) => setTimeout(res, 5000));
    console.log('TIMEOUT END');
    res.end();
  }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question