Skip to content

RESTController.handleError discards error.cause, making network failures hard to diagnose #3150

Open

Description

@Stovedal

New Issue Checklist

Issue Description

RESTController.handleError discards error.cause which makes it hard to debug what the actual cause of the network error is. This caused some issues for us when we were debugging elevated levels of network failure.

Node's fetch throws TypeError: fetch failed and stores the real reason on .cause, in our case SocketError: other side closed with code: 'UND_ERR_SOCKET'. handleError sees errorJSON.message === 'fetch failed' and takes the first branch:

https://github.com/parse-community/Parse-SDK-JS/blob/alpha/src/RESTController.ts#L359-L371

if (errorJSON.code || errorJSON.error || errorJSON.message) {
  error = new ParseError(errorJSON.code, errorJSON.error || errorJSON.message);
}

errorJSON.code is undefined for a TypeError so the resulting ParseError has no code and cause is never carried across.

We do already have the cause, it is inspected earlier on L240, so it should be easy to attach.

Steps to reproduce

const http = require('http')
const Parse = require('parse/node')

const run = async () => {
  const server = http.createServer((req) => req.socket.destroy())
  await new Promise((r) => server.listen(0, '127.0.0.1', r))

  Parse.initialize('appId', null, 'masterKey')
  Parse.serverURL = `http://127.0.0.1:${server.address().port}/parse`

  try {
    await new Parse.Query('Foo').first({ useMasterKey: true })
  } catch (e) {
    console.log('code   :', e.code)
    console.log('message:', JSON.stringify(e.message))
    console.log('cause  :', e.cause)
  }
  server.close()
  process.exit(0)
}
run()

Actual Outcome

code   : undefined
message: "fetch failed"
cause  : undefined

Expected Outcome

The underlying cause survives, so callers can tell retryable connection failures apart from DNS or TLS problems:

code   : undefined
message: "fetch failed"
cause  : SocketError: other side closed { code: 'UND_ERR_SOCKET' }

Opened #3149 with a fix and a regression test.

Environment

Server

  • Parse Server version: 9.9.0
  • Operating system: Ubuntu 26.04 (Heroku-26 stack), Node.js 24.16.0
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Heroku

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: n/a - the reproduction requires no database
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): MongoDB Atlas

Client

  • Parse JS SDK version: 8.6.2 (also reproduced on 8.6.0; the relevant code is unchanged on alpha)

Related: #3148 covers the retry behaviour for these same failures.

Activity

  1. parse-github-assistant commented on Oct 15, 2026

    @parse-github-assistant

    🚀 Thanks for opening this issue!

    ℹ️ You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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