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

server.timeout is not closing the execution of an request #36130

Open
sincerekamal opened this issue Nov 15, 2020 · 3 comments
Open

server.timeout is not closing the execution of an request #36130

sincerekamal opened this issue Nov 15, 2020 · 3 comments
Labels
http Issues or PRs related to the http subsystem.

Comments

@sincerekamal
Copy link

  • Version: 12.16.2
  • Platform: Windows 10
  • Subsystem:

What steps will reproduce the bug?

How often does it reproduce? Is there a required condition?

It can be reproduced all the time. The issue is, I have created the http server using http.createServer() and had set the server.timeout = X; expecting the server to close the connection when the request is processed for more than "X" milliseconds, but it's not working as expected. The request is processed and responded even long after time.

If my understanding is incorrect, could you guide me something similar to max_execution_time in PHP ?

What I basically want is, I want my node http server to return 504 error when it's not able to respond within "X" milliseconds.

What is the expected behavior?

Returning 504 timeout error

What do you see instead?

200 success response

Additional information

@ahwayakchih
Copy link

ahwayakchih commented Nov 16, 2020

Could you add basic code that shows how you start processing request? Because for now i would guess that you start processing on main thread and keep it busy for a long time, so timeout has no chance of being triggered.

Start long-running processes, that do not allow main event loop to continue, in a separate worker or a child process.

@sincerekamal
Copy link
Author

@ahwayakchih I think, you got it. So, do you mean for each request I should spawn a worker/child process ? Is there any alternate way ?

@ahwayakchih
Copy link

You can spawn a single (or a few) "workers", a "job queue" process (or just use one of the databases best for such tasks), and add jobs to queue. How you resolve that is up to you (or many tutorials/guides available elsewhere) - i don't think node.js issue is a place for that.

@PoojaDurgad PoojaDurgad added the http Issues or PRs related to the http subsystem. label Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants