You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2022/10/31 11:21:03 UTC

[GitHub] [couchdb-nano] insidewhy opened a new pull request, #310: Abort HTTP connection when stopping changesReader, fixes #309

insidewhy opened a new pull request, #310:
URL: https://github.com/apache/couchdb-nano/pull/310

   <!-- Thank you for your contribution!
   
        Please file this form by replacing the Markdown comments
        with your text. If a section needs no action - remove it.
   
        Also remember, that CouchDB uses the Review-Then-Commit (RTC) model
        of code collaboration. Positive feedback is represented +1 from committers
        and negative is a -1. The -1 also means veto, and needs to be addressed
        to proceed. Once there are no objections, the PR can be merged by a
        CouchDB committer.
   
        See: http://couchdb.apache.org/bylaws.html#decisions for more info. -->
   
   ## Overview
   
   <!-- Please give a short brief for the pull request,
        what problem it solves or how it makes things better. -->
   
   ## Testing recommendations
   
   <!-- Describe how we can test your changes.
        Does it provides any behaviour that the end users
        could notice? -->
   
   ## GitHub issue number
   
   <!-- If this is a significant change, please file a separate issue at:
        https://github.com/apache/couchdb-nano/issues
        and include the number here and in commit message(s) using
        syntax like "Fixes #472" or "Fixes apache/couchdb#472".  -->
   
   ## Related Pull Requests
   
   <!-- If your changes affects multiple components in different
        repositories please put links to those pull requests here.  -->
   
   ## Checklist
   
   - [ ] Code is written and works correctly;
   - [ ] Changes are covered by tests;
   - [ ] Documentation reflects the changes;
   


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb-nano] insidewhy commented on a diff in pull request #310: Abort HTTP connection when stopping changesReader, fixes #309

Posted by GitBox <gi...@apache.org>.
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb-nano] insidewhy commented on a diff in pull request #310: Abort HTTP connection when stopping changesReader, fixes #309

Posted by GitBox <gi...@apache.org>.
insidewhy commented on code in PR #310:
URL: https://github.com/apache/couchdb-nano/pull/310#discussion_r1009304030


##########
lib/nano.js:
##########
@@ -172,6 +172,16 @@ module.exports = exports = function dbScope (cfg) {
       body = { message: body }
     }
 
+    if (!body && req.signal) {

Review Comment:
   `req.signal.aborted` should be `true` also, but (at least in the tests) this doesn't seem to occur.



-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb-nano] glynnbird commented on pull request #310: Abort HTTP connection when stopping changesReader, fixes #309

Posted by GitBox <gi...@apache.org>.
glynnbird commented on PR #310:
URL: https://github.com/apache/couchdb-nano/pull/310#issuecomment-1301864041

   Thanks @insidewhy. I was just trying to fix this up. Thanks for doing so! I'm preparing a new release :) 


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb-nano] glynnbird merged pull request #310: Abort HTTP connection when stopping changesReader, fixes #309

Posted by GitBox <gi...@apache.org>.
glynnbird merged PR #310:
URL: https://github.com/apache/couchdb-nano/pull/310


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb-nano] insidewhy commented on a diff in pull request #310: Abort HTTP connection when stopping changesReader, fixes #309

Posted by GitBox <gi...@apache.org>.
insidewhy commented on code in PR #310:
URL: https://github.com/apache/couchdb-nano/pull/310#discussion_r1009304030


##########
lib/nano.js:
##########
@@ -172,6 +172,16 @@ module.exports = exports = function dbScope (cfg) {
       body = { message: body }
     }
 
+    if (!body && req.signal) {

Review Comment:
   `req.signal.aborted` should be `true` also, but (at least in the tests) this doesn't seem to occur.



-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb-nano] glynnbird commented on pull request #310: Abort HTTP connection when stopping changesReader, fixes #309

Posted by GitBox <gi...@apache.org>.
glynnbird commented on PR #310:
URL: https://github.com/apache/couchdb-nano/pull/310#issuecomment-1301903963

   waiting for Travis ...


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org