question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught promise

See original GitHub issue

Describe the bug

Uncaught promise!

There is a rule in Node.JS that you must surround all new Promises with a catch. This is typically done using try ... catch inbetween async await syntax, or using the chainable Promise .catch() interface.

The fact that a promise was created without this structure indicates that the apm node programmer may not have understood a fundamental concept, and therefore you might also want to review all other Promise structures throughout the code, to be thorough about how these are handled.

The side-effect is that while APM is loaded, some redis errors are not catchable, therefore the application cannot recover from failure.

A secondary future effect is that the process may be forced to exit.

{
	"ts": "2019-11-13T21:46:58.039Z",
	"src": "internal/process/warning.js:27:3",
	"error": "(node:19157) UnhandledPromiseRejectionWarning: ReplyError: WRONGTYPE Operation against a key holding the wrong kind of value\n    at parseError (/workspace/projectX/node_modules/redis-parser/lib/parser.js:179:12)\n    at parseType (/workspace/projectX/node_modules/redis-parser/lib/parser.js:302:14)",
	"data": {}
}
{
	"ts": "2019-11-13T21:46:58.040Z",
	"src": "internal/process/warning.js:27:3",
	"error": "(node:19157) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)",
	"data": {}
}
{
	"ts": "2019-11-13T21:46:58.040Z",
	"src": "internal/process/warning.js:27:3",
	"error": "(node:19157) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.",
	"data": {}
}

To Reproduce

Steps to reproduce the behavior:

  1. Create a Hash by means necessary. HSET a b c
  2. Then try to read it with the wrong command, using ioredis library with elastic-apm-node module loaded. GET a
  3. Observe error thrown. While it is correct that Redis error should be thrown here, it is INCORRECT that it should be made UNCATCHABLE due to interference by the APM library, resulting in process exit.

Expected behavior

I expect when such an error is thrown, that I can catch and handle it. Like so:

(async () => {
try {
  await redis.hget('a');
}
catch(e) {
  debugger; // should break here, but doesn't (only while APM is loaded)
}
})();

Environment (please complete the following information)

  • OS: Linux
  • Node.js version: v12.12.0
  • APM Server version: N/A
  • Agent version: 3.1.0

How are you starting the agent? (please tick one of the boxes)

  • Calling agent.start() directly (e.g. require('elastic-apm-node').start(...))
  • Requiring elastic-apm-node/start from within the source code
  • Starting node with -r elastic-apm-node/start

Additional context

APM is nice. Plz fix. Also we’re a paying elastic enterprise customer (Ancestry)

package.json

    "elastic-apm-node": "^3.1.0",
    "ioredis": "^4.11.2",

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
axwcommented, Nov 19, 2019

The fix has been released in v3.2.0.

0reactions
ancms2600commented, Nov 15, 2019

Thank you! ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Uncaught (in promise) undefined" error when using with ...
The problem I have is that with the parameter &with=location I get an error Uncaught (in promise) undefined at this part of my...
Read more >
Promises - Error Handling - Beginner JavaScript - Wes Bos
What does that log "Uncaught (in promise)" mean? It means that there was an error in one of our promises, but we did...
Read more >
JavaScript (ES2015) Promise error “Uncaught (in promise ...
JavaScript (ES2015) Promise error “Uncaught (in promise) {reject message}” ... I'm working on a simple script to test JavaScript Promises ...
Read more >
How to handle Uncaught (in promise) DOMException ... - Quora
It means that you have a right parenthesis somewhere that you shouldn't. The error should give you a row and column number indicating...
Read more >
How to debug Error (In Promise) Uncaught - YouTube
We are debugging Uncaught (in Promise ) status 400 error in Axios.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found