Skip to content

Server crashes because response.cause doesn't exist #356

@csabaxyz

Description

@csabaxyz

I updated to nano v11 and started getting server crashes in my local dev environment, because of this line:

response.statusText = response.cause.toString()

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions