You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "csabaxyz (via GitHub)" <gi...@apache.org> on 2025/09/13 00:52:36 UTC

[I] Server crashes because `response.cause` doesn't exist [couchdb-nano]

csabaxyz opened a new issue, #356:
URL: https://github.com/apache/couchdb-nano/issues/356

   I updated to nano v11 and started getting server crashes in my local dev environment, because of this line:
   https://github.com/apache/couchdb-nano/blob/26fb0e11111f997a40bc9556496d296767ea8c77/lib/nano.js#L131
   
   Looks like the response doesn't have a `cause` property:
   ```
   126 |     const responseHeaders = Object.assign({
   127 |       uri: scrubURL(req.url),
   128 |       statusCode
   129 |     }, response.headers ? response.headers : {})
   130 |     if (!response.status) {
   131 |       response.statusText = response.cause.toString()
                                              ^
   TypeError: undefined is not an object (evaluating 'response.cause.toString')
         at <anonymous> (/opt/src/node_modules/nano/lib/nano.js:131:38)
         at responseHandler (/opt/src/node_modules/nano/lib/nano.js:112:43)
         at <anonymous> (/opt/src/node_modules/nano/lib/nano.js:431:11)
   ```
   
   For reference I'm using Bun instead of Node.js, so that might be the real culprit, but the fix is either `response.cause?.toString()` or adding a fallback cause.


-- 
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.apache.org

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


Re: [I] Server crashes because `response.cause` doesn't exist [couchdb-nano]

Posted by "glynnbird (via GitHub)" <gi...@apache.org>.
glynnbird closed issue #356: Server crashes because `response.cause` doesn't exist
URL: https://github.com/apache/couchdb-nano/issues/356


-- 
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


Re: [I] Server crashes because `response.cause` doesn't exist [couchdb-nano]

Posted by "digitalextremist (via GitHub)" <gi...@apache.org>.
digitalextremist commented on issue #356:
URL: https://github.com/apache/couchdb-nano/issues/356#issuecomment-3287407010

   Seems like it was the same call before the change:
   
   https://github.com/apache/couchdb-nano/commit/26fb0e11111f997a40bc9556496d296767ea8c77#diff-695d68e8a3fa741f813071eb65314036c1d066217057473e897d0d33104cbe34L445
   
   But that yes, the `response.cause.toString()` call is new:
   
   https://github.com/apache/couchdb-nano/commit/26fb0e11111f997a40bc9556496d296767ea8c77#diff-695d68e8a3fa741f813071eb65314036c1d066217057473e897d0d33104cbe34L140


-- 
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


Re: [I] Server crashes because `response.cause` doesn't exist [couchdb-nano]

Posted by "digitalextremist (via GitHub)" <gi...@apache.org>.
digitalextremist commented on issue #356:
URL: https://github.com/apache/couchdb-nano/issues/356#issuecomment-3287401656

   Also using `Bun` here @csabaxyz; and have not seen this:
   
   Curious what led up to this? What operation was being performed?
   
   The stack-trace seems to start from here:
   
   https://github.com/apache/couchdb-nano/blob/26fb0e11111f997a40bc9556496d296767ea8c77/lib/nano.js#L431
   
   Seems `responseHandler` is actually being sent `error` rather than `response` is the root issue, before the apparent error.


-- 
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


Re: [I] Server crashes because `response.cause` doesn't exist [couchdb-nano]

Posted by "csabaxyz (via GitHub)" <gi...@apache.org>.
csabaxyz commented on issue #356:
URL: https://github.com/apache/couchdb-nano/issues/356#issuecomment-3287835196

   > Curious what led up to this? What operation was being performed?
   
   Essentially I was in the process of implementing a minimal migration script to setup the database before the rest of the code runs, and that code runs when the Docker containers are coming online, so the initial connection can actually go to a non-existent database service. So, when the error happens the request looks like this:
   ```js
   {
     url: "http://couch:5984/_session",
     method: "post",
     headers: {
       accept: "application/json",
       "user-agent": "nano/11.0.0 (Node.js v24.3.0)",
       "Accept-Encoding": "deflate, gzip",
       "content-type": "application/x-www-form-urlencoded; charset=utf-8",
     },
     credentials: "include",
     body: URLSearchParams {
       "name": "***",
       "password": "***",
     },
     redirect: "error",
     signal: undefined,
     bodyTimeout: 0,
   }
   ```
   
   But you are right, when I was using `v10` the error was swallowed in the retry logic. I downgraded to see what the error was before:
   ```
   152 |         return
   153 |       }
   154 | 
   155 |       log({ err: 'socket', body, headers: responseHeaders })
   156 |       if (reject) {
   157 |         reject(new Error(`error happened in your connection. Reason: ${response.message}`))
                        ^
   error: error happened in your connection. Reason: ECONNREFUSED
         at responseHandler (/opt/src/node_modules/nano/lib/nano.js:157:16)
         at <anonymous> (/opt/src/node_modules/nano/lib/nano.js:456:13)
   ```


-- 
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


Re: [I] Server crashes because `response.cause` doesn't exist [couchdb-nano]

Posted by "digitalextremist (via GitHub)" <gi...@apache.org>.
digitalextremist commented on issue #356:
URL: https://github.com/apache/couchdb-nano/issues/356#issuecomment-3289200833

   Thank you for the extra context @csabaxyz; that helps and makes sense. I feel the issue is in the open now.
   
   I suspect a refactor is needed to _really_ fix the issue, but I put up a PR ( #358 linked above ) to think about.


-- 
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