Increase usefulness of dgraph-js stack traces

Experience Report for Feature Request

Note: Feature requests are judged based on user experience and modeled on Go Experience Reports. These reports should focus on the problems: they should not focus on and need not propose solutions.

What you wanted to do

Get useful stack traces from dgraph-js when something goes wrong.

What you actually did

Got stack traces anchored inside the dgraph-js module because the error objects are created in one place: dgraph-js/errors.js at master · dgraph-io/dgraph-js · GitHub

Why that wasn’t great, with examples

If a request fails because, say, Dgraph aborts the transaction for some reason, the err object includes a useless stack trace:

Error: Transaction has been aborted. Please retry
    at Object.<anonymous> (/app/core/node_modules/dgraph-js/lib/errors.js:6:23)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at Module.Hook._require.Module.require (/app/core/node_modules/require-in-the-middle/index.js:80:39)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/app/core/node_modules/dgraph-js/lib/clientStub.js:43:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at Module.Hook._require.Module.require (/app/core/node_modules/require-in-the-middle/index.js:80:39)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/app/core/node_modules/dgraph-js/lib/dgraph.js:24:14)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)

This stack trace doesn’t reference the calling code.

Any external references to support your case

This isn’t strictly a feature or strictly a bug, so I wasn’t sure which to pick.

When it says retry, just wait a sec or minute and retry. There is nothing related to the code. Your cluster may be busy or something.