insidewhy commented on code in PR #310:
URL: https://github.com/apache/couchdb-nano/pull/310#discussion_r1009304585


##########
test/document.changesreader.test.js:
##########
@@ -505,3 +505,28 @@ test('should survive malformed JSON - 
db.changesReader.start', async () => {
     })
   })
 }, 10000)
+
+test('should cancel HTTP connection as soon as stop is called', async () => {
+  const changeURL = `/${DBNAME}/_changes`
+  nock(COUCH_URL)
+    .post(changeURL)
+    .query({ feed: 'longpoll', timeout: 60000, since: 'now', limit: 100, 
include_docs: false })
+    .reply(200, { results: [], last_seq: '1-0', pending: 0 })
+    .post(changeURL)
+    .delay(60000)
+    .reply(500)
+  const db = nano.db.use(DBNAME)
+  const cr = db.changesReader.start()
+  await new Promise((resolve, reject) => {
+    cr.on('seq', function (seq) {
+      setTimeout(function () {
+        // give the next http connection a chance to be established
+        db.changesReader.stop()
+      }, 200)
+    })
+
+    cr.on('end', function () {
+      resolve()

Review Comment:
   Without the code in this PR the test times out (wrote the test first).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to