This is an automated email from the ASF dual-hosted git repository.

glynnbird pushed a commit to branch fetch
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git

commit 529f5069afe63ae96425f234c8dd2f1dfc5463a3
Author: Glynn Bird <[email protected]>
AuthorDate: Tue Dec 13 13:55:48 2022 +0000

    tidy up
---
 .travis.yml          |  3 +--
 README.md            |  1 -
 lib/changesreader.js |  6 +++---
 lib/nano.js          | 31 +++++++++++++------------------
 package-lock.json    | 14 +++++++-------
 package.json         |  2 +-
 6 files changed, 25 insertions(+), 32 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a92acf6..deeef4f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,8 @@
 dist: focal
 language: "node_js"
 node_js:
-  - "14"
-  - "16"
   - "18"
+  - "19"
 services:
   - docker
 os:
diff --git a/README.md b/README.md
index 49b9c21..1c29471 100644
--- a/README.md
+++ b/README.md
@@ -1334,7 +1334,6 @@ npm run test
 [2]: https://github.com/apache/couchdb-nano/issues
 [4]: https://github.com/apache/couchdb-nano/blob/main/cfg/couch.example.js
 [8]: https://webchat.freenode.net?channels=%23couchdb-dev
-[axios]:  https://github.com/axios/axios
 
 https://freenode.org/
 
diff --git a/lib/changesreader.js b/lib/changesreader.js
index 5093b4c..98ca422 100644
--- a/lib/changesreader.js
+++ b/lib/changesreader.js
@@ -279,6 +279,9 @@ class ChangesReader {
     const lin = liner()
     const cp = changeProcessor(self.ee, self.batchSize)
     self.request(req)
+      .on(EVENT_ERROR, (e) => {
+        self.ee.emit(EVENT_ERROR, e)
+      })
       .pipe(lin)
       .pipe(cp)
       .on('finish', (lastSeq) => {
@@ -287,9 +290,6 @@ class ChangesReader {
           self.ee.emit('end', cp.lastSeq)
         }, 10)
       })
-      .on(EVENT_ERROR, (e) => {
-        self.ee.emit(EVENT_ERROR, e)
-      })
 
     return self.ee
   }
diff --git a/lib/nano.js b/lib/nano.js
index aa7845f..103b919 100644
--- a/lib/nano.js
+++ b/lib/nano.js
@@ -10,17 +10,17 @@
 // License for the specific language governing permissions and limitations 
under
 // the License.
 
-// const { HttpsCookieAgent, HttpCookieAgent } = 
require('http-cookie-agent/http')
 const { URL } = require('url')
-const { Readable } = require('node:stream')
 const assert = require('assert')
-const { tough, cookieJar } = require('./cookiejar.js')
 const stream = require('stream')
-const pkg = require('../package.json')
+const Readable = stream.Readable
 const undici = require('undici')
-const SCRUBBED_STR = 'XXXXXX'
 const ChangesReader = require('./changesreader.js')
+const { tough, cookieJar } = require('./cookiejar.js')
 const MultiPartFactory = require('./multipart.js')
+const pkg = require('../package.json')
+
+const SCRUBBED_STR = 'XXXXXX'
 
 function isEmpty (val) {
   return val == null || !(Object.keys(val) || val).length
@@ -65,10 +65,7 @@ module.exports = exports = function dbScope (cfg) {
   assert.ok(/^https?:/.test(cfg.url), 'url is not valid')
 
   cfg = Object.assign({}, cfg)
-
   serverScope.config = cfg
-  // cfg.requestDefaults = cfg.requestDefaults || {}
-
   const dummyLogger = () => {}
   const log = typeof cfg.log === 'function' ? cfg.log : dummyLogger
   const parseUrl = 'parseUrl' in cfg ? cfg.parseUrl : true
@@ -115,13 +112,6 @@ module.exports = exports = function dbScope (cfg) {
     if (req.headers.cookie) {
       req.headers.cookie = 'XXXXXXX'
     }
-    if (req.auth) {
-      if (!cloned) {
-        req.auth = JSON.parse(JSON.stringify(req.auth)) // clone just auth if 
not already cloned
-      }
-      req.auth.username = SCRUBBED_STR
-      req.auth.password = SCRUBBED_STR
-    }
     if (req.headers.Authorization) {
       req.headers.Authorization = 'XXXXXXX'
     }
@@ -165,7 +155,8 @@ module.exports = exports = function dbScope (cfg) {
     delete responseHeaders['content-length']
 
     if (statusCode >= 200 && statusCode < 400) {
-      log({ err: null, body, headers: responseHeaders })
+
+      // collect response
       const ct = response.headers.get('content-type')
       let retval = ''
       if (ct === 'application/json') {
@@ -180,6 +171,10 @@ module.exports = exports = function dbScope (cfg) {
         const ab = await response.arrayBuffer()
         retval = Buffer.from(ab)
       }
+
+      // log
+      log({ err: null, retval, headers: responseHeaders })
+
       // promisey
       if (resolve) {
         resolve(retval)
@@ -402,8 +397,8 @@ module.exports = exports = function dbScope (cfg) {
       credentials: 'include',
       body: method !== 'get' && body ? body : undefined,
       redirect: 'error',
-      keepalive: true,
-      signal: opts.signal
+      signal: opts.signal,
+      bodyTimeout: 0
     }
 
     // add custom agent if present
diff --git a/package-lock.json b/package-lock.json
index 4c8cc28..db8229c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,7 +10,7 @@
       "license": "Apache-2.0",
       "dependencies": {
         "tough-cookie": "^4.1.2",
-        "undici": "^5.13.0"
+        "undici": "^5.14.0"
       },
       "devDependencies": {},
       "engines": {
@@ -74,9 +74,9 @@
       }
     },
     "node_modules/undici": {
-      "version": "5.13.0",
-      "resolved": "https://registry.npmjs.org/undici/-/undici-5.13.0.tgz";,
-      "integrity": 
"sha512-UDZKtwb2k7KRsK4SdXWG7ErXiL7yTGgLWvk2AXO1JMjgjh404nFo6tWSCM2xMpJwMPx3J8i/vfqEh1zOqvj82Q==",
+      "version": "5.14.0",
+      "resolved": "https://registry.npmjs.org/undici/-/undici-5.14.0.tgz";,
+      "integrity": 
"sha512-yJlHYw6yXPPsuOH0x2Ib1Km61vu4hLiRRQoafs+WUgX1vO64vgnxiCEN9dpIrhZyHFsai3F0AEj4P9zy19enEQ==",
       "dependencies": {
         "busboy": "^1.6.0"
       },
@@ -148,9 +148,9 @@
       }
     },
     "undici": {
-      "version": "5.13.0",
-      "resolved": "https://registry.npmjs.org/undici/-/undici-5.13.0.tgz";,
-      "integrity": 
"sha512-UDZKtwb2k7KRsK4SdXWG7ErXiL7yTGgLWvk2AXO1JMjgjh404nFo6tWSCM2xMpJwMPx3J8i/vfqEh1zOqvj82Q==",
+      "version": "5.14.0",
+      "resolved": "https://registry.npmjs.org/undici/-/undici-5.14.0.tgz";,
+      "integrity": 
"sha512-yJlHYw6yXPPsuOH0x2Ib1Km61vu4hLiRRQoafs+WUgX1vO64vgnxiCEN9dpIrhZyHFsai3F0AEj4P9zy19enEQ==",
       "requires": {
         "busboy": "^1.6.0"
       }
diff --git a/package.json b/package.json
index 61d00b0..8f3fd8f 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
   ],
   "dependencies": {
     "tough-cookie": "^4.1.2",
-    "undici": "^5.13.0"
+    "undici": "^5.14.0"
   },
   "devDependencies": {
   },

Reply via email to