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

[ERROR] 15:13:55 Error: Cannot set headers after they are sent to the client #58530

Closed
yizhishiliu opened this issue May 14, 2024 · 3 comments
Closed
Labels
Question An issue which isn't directly actionable in code

Comments

@yizhishiliu
Copy link

🔎 Search Terms

Error: Cannot set headers after they are sent to the client

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

No response

💻 Code

// Your code here

🙁 Actual behavior

Using typescript to write the backend interface, this error message appears after a normal response to a request, causing the entire program to end abnormally, unable to respond to subsequent requests.
[ERROR] 15:13:55 Error: Cannot set headers after they are sent to the client

🙂 Expected behavior

The request is responded to normally and does not affect the normal execution of other requests.

Additional information about the issue

No response

@MartinJohns
Copy link
Contributor

This is completely unrelated to TypeScript.

@yizhishiliu
Copy link
Author

yizhishiliu commented May 15, 2024

Adding "@res() res: Response" to the controller's method parameter successfully solved the response problem.

As:

`
import { Controller, Get, Res } from '@nestjs/common';
import { Response } from 'express';

@controller('test')
export class CatsController {
@get()
testRes(@res() res: Response) {
res.status(200).send('OK');
}
}
`

@RyanCavanaugh
Copy link
Member

It looks like this is a question rather than a bug report. This issue tracker is for tracking bugs and active work on TypeScript itself, rather than a general forum for programmers using TypeScript to get help or ask questions.

You can ask questions on sites like Stack Overflow. We are not able to provide one-on-one support on the issue tracker. Please read the issue template carefully - it has important information on what kinds of reports can be acted on here, as well as links to useful TypeScript resources. Thanks!

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants