node-restify icon indicating copy to clipboard operation
node-restify copied to clipboard

Restify JSON client error is showing a type "F" instead of object

Open rahulraykor opened this issue 5 years ago • 2 comments

Restify Version

"restify": "7.6.0",
"restify-clients": "2.6.4"

Node.js Version

10.7.0

Expected behaviour

Restify JSON client should provide error as JSON object

Actual behaviour

It is giving error of some "F" type. See attached screenshot.

Repro case

  1. Create a JSON client.
  2. Give get request from JSON client to unavailable endpoint (to generate error) and check the JSON in debug
  3. You will see it as "F" type.

image

rahulraykor avatar Mar 20 '19 07:03 rahulraykor

Below is the stack, I am getting in the above error: "NotFoundError at Object.createHttpErr (/usr/src/node_modules/restify-clients/lib/helpers/errors.js:91:26) at ClientRequest.onResponse (/usr/src/node_modules/restify-clients/lib/HttpClient.js:309:26) at Object.onceWrapper (events.js:273:13) at ClientRequest.emit (events.js:182:13) at ClientRequest.EventEmitter.emit (domain.js:441:20) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17) at Socket.socketOnData (_http_client.js:442:20) at Socket.emit (events.js:182:13) at Socket.EventEmitter.emit (domain.js:441:20)"

Is it issue while parsing restify error object like https://github.com/restify/node-restify/issues/1410?

rahulraykor avatar Mar 20 '19 08:03 rahulraykor

The constructors for the errors used by restify-clients and restify come from restify-errors. It looks like your IDE is picking up the method in which we dynamically construct the error: https://github.com/restify/errors/blob/master/lib/index.js#L57

That certainly doesn't seem great. Does F instanceof Error return true? The return value should continue to be a real error object.

DonutEspresso avatar Apr 20 '19 07:04 DonutEspresso