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

setTimeout not working? Can't throttle server... #220

Open
mellis481 opened this issue Oct 14, 2020 · 0 comments
Open

setTimeout not working? Can't throttle server... #220

mellis481 opened this issue Oct 14, 2020 · 0 comments

Comments

@mellis481
Copy link

I'd essentially like to create a throttled server. I thought I could do something like this:

require('http').createServer(function (request, response) {
  request.addListener('end', function () {
    setTimeout(function () { fileServer.serve(request, response); }, 2000);
  }).resume();
}).listen(8080);

As you can see, I've wrapped my server() call in a setTimeout. This doesn't seem to be working, though.

How can I throttle my server?

@mellis481 mellis481 changed the title setTimeout not working? setTimeout not working? Can't throttle server... Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant