Skip to content

Instantly share code, notes, and snippets.

@leozc
Last active July 23, 2018 20:15
Show Gist options
  • Save leozc/4667579 to your computer and use it in GitHub Desktop.
Save leozc/4667579 to your computer and use it in GitHub Desktop.
Node.js HTTP sleep server Simulate HTTP Timeout error
var http = require('http');
var sleep = require('sleep');
var timeout = 100000; //sleep 100 seconds
http.createServer(function (req, res) {
setTimeout((function() {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("Hello I am awake");
}), timeout);
}).listen(8080);
@patrick-steele
Copy link

Nice! But I don't see any use of the sleep module. I've removed it and it still works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment