Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This middleware will keep the request stream open indefinitely, pad the initial

Detailed information on how to setup the browser/client can be found [here][1].

The client can be forced to disconnect by calling res.end().

Installation
--------

Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ function sse(req, res, next) {
res.sse(':keep-alive\n\n');
}, 20000);

// cleanup on close
// cleanup on close and finish
res.on('close', function close() {
clearInterval(keepAlive);
});
res.on('finish', function finish() {
clearInterval(keepAlive);
});

next();
}
Expand Down