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.

Pool > Execute > Uncaught error

See original GitHub issue

We experience a problem with execute(); it errors and we cannot handle in the immediate codeblock, is handled outside the immediate try/catch context.

execute() works outright in this context, however we receive this error after 20 mins of app runtime for some reason.

Q. Does anything look untoward in the execute() debug, below?

Add command: Prepare
Add command: Execute
6 13392050 <== Execute#unknown name(0,,81)
6 13392050 <== 4d000000170300000000010000000001fd00fd00050018494e564f4b45442072656672657368546f6b656e545328291941636365737320746f6b656e2068617320657870697265642e00807dad852d7842
Add command: Prepare
Add command: Execute
2 13392018 <== Execute#unknown name(0,,42)
2 13392018 <== 26000000170300000000010000000201fd00060005000a52454652455348494e4700807dad852d784200
Add command: Prepare
0 13392019 <== Prepare#unknown name(0,,27)
0 13392019 <== 170000001653454c45435420746f6b656e2046524f4d2075736572
Add command: Execute
Fri Aug 26 2022 16:13:28 GMT+1200 (New Zealand Standard Time) 1661487208417 Error {"stack":"UnhandledPromiseRejection: 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(). The promise rejected with the reason \"#<Object>\".","message":"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(). The promise rejected with the reason \"#<Object>\".","name":"UnhandledPromiseRejection","code":"ERR_UNHANDLED_REJECTION"}

db = mysql.createPool({
        ..._oConfig,
        waitForConnections: true,
        connectionLimit: 10,
        queueLimit: 0,
        debug: true,
});

const myFunction = async () => {
    try {
        const [rows, fields] = await db.execute('SELECT * FROM user', []);
    } catch (oError) {
        console.log('HUH',oError); // NOTE: Not caught!
    }
};

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelpeterleecommented, Aug 31, 2022

Thanks for responding, much appreciated.

We will not implement this library until errors bubble to callee.

0reactions
t638403commented, Dec 9, 2022

Does not seem to work for me either.

Using "mysql2": "^2.3.3".

It errors because of a missing value for publish in the data whlie it is defined as a named parameter.

TypeError: Bind parameters must not contain undefined. To pass SQL NULL specify JS null

This is my code:

const mysql = require('mysql2/promise');
(async () => {

  const pool = mysql.createPool({
    host:     process.env.MYSQL_HOST,
    database: process.env.MYSQL_DATABASE,
    port:     process.env.MYSQL_PORT,
    user:     process.env.MYSQL_USER,
    password: process.env.MYSQL_PASSWORD,
    namedPlaceholders: true
  });
  const sql = `INSERT INTO content (name, content, publish) VALUES (:name, :content, :publish})`;
  try {
    const response = await pool.execute(sql, {name:'some name', content:'some content'});
    console.log(response);
  } catch (e) {
    console.log('Hooray I caught an error.')
  }

})();
Read more comments on GitHub >

github_iconTop Results From Across the Web

uncatchable uncaughtException in pool.execute if undefined ...
In my case the server will crash&restart on uncaughtException / unhandledRejection , so I try to add catch for most error.
Read more >
java - Why is UncaughtExceptionHandler not called by ...
The threads are being started with a Runnable implementation which fetches other Runanbles (your Runnables) from the ExecutorService and executes them: ...
Read more >
How to Handle Died Threads due to Uncaught Exceptions in ...
My personal preference especially while using multiple thread pools is overriding afterExecute() method, and calling execute() again on detecting an uncatched ...
Read more >
TPS03-J. Ensure that tasks executing in a thread pool do not ...
This compliant solution sets an uncaught exception handler on behalf of the thread pool. A ThreadFactory argument is passed to the thread pool...
Read more >
"An uncaught thread exception was caught by the threadpool ...
Errors: "An uncaught thread exception was caught by the threadpool. java.lang. ... SocketReaderRequest.execute(SocketReaderRequest.java:42)
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