You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2016/02/16 21:06:52 UTC

[1/2] couch commit: updated refs/heads/master to f3b7f5a

Repository: couchdb-couch
Updated Branches:
  refs/heads/master 0aae568e2 -> f3b7f5a47


Send a real EventSource event for heartbeat

Bring back 845bf7529a3bc565d6446a7fa6cc5fd1a140653e

The EventSource connection can get stuck (in TCP half-open state*) and there's no way
for the client to detect that. This commit changes the way heartbeat is sent, instead of
sending a newline character, it sends an empty event of type heartbeat:

    event: heartbeat
    data:

This event doesn't have an id: field, so the client will retain its latest Last-Event-ID state.

This doesn't change the expectations of clients that used EventSource till now, because they
subscribe to the 'message' event type. To get the 'heartbeat' events a client will need to
explicitly subscribe to it:

    source.addEventListener('heartbeat', function () { /* cancel a timer that would otherwise reconnect the source */ });

* this can happen when you suspend your laptop, on flaky internet connection, ADSL reconnect,
bad wifi signals, bad routers etc. Pretty often in a typical internet usage nowadays.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/11896807
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/11896807
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/11896807

Branch: refs/heads/master
Commit: 11896807f1d27eee8789cee36bdf2c38ede42916
Parents: 010704a
Author: Damjan Georgievski <gd...@gmail.com>
Authored: Fri May 2 17:04:41 2014 +0200
Committer: Damjan Georgievski <gd...@gmail.com>
Committed: Tue Feb 9 18:48:30 2016 +0100

----------------------------------------------------------------------
 src/couch_httpd_db.erl | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/11896807/src/couch_httpd_db.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd_db.erl b/src/couch_httpd_db.erl
index 7f2ae1c..965e8fb 100644
--- a/src/couch_httpd_db.erl
+++ b/src/couch_httpd_db.erl
@@ -111,6 +111,8 @@ handle_changes_req1(Req, #db{name=DbName}=Db, ChangesArgs, ChangesFun) ->
                 io_lib:format("\n],\n\"last_seq\":~w}\n", [EndSeq])
             ),
             couch_httpd:end_json_response(Resp);
+        (timeout, "eventsource") ->
+            couch_httpd:send_chunk(Resp, "event: heartbeat\ndata: \n\n");
         (timeout, _) ->
             couch_httpd:send_chunk(Resp, "\n")
         end


[2/2] couch commit: updated refs/heads/master to f3b7f5a

Posted by kx...@apache.org.
Merge remote-tracking branch 'github/pr/137'


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/f3b7f5a4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/f3b7f5a4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/f3b7f5a4

Branch: refs/heads/master
Commit: f3b7f5a47379dd269e7c436ecf26a1239d7b6907
Parents: 0aae568 1189680
Author: Alexander Shorin <kx...@apache.org>
Authored: Tue Feb 16 23:06:06 2016 +0300
Committer: Alexander Shorin <kx...@apache.org>
Committed: Tue Feb 16 23:06:06 2016 +0300

----------------------------------------------------------------------
 src/couch_httpd_db.erl | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------