# Unhandled ExclusiveLock Exception in Node.js with Neo4j 5.26.1 – Unable to Catch the Error

**URL:** <https://community.neo4j.com/t/unhandled-exclusivelock-exception-in-node-js-with-neo4j-5-26-1-unable-to-catch-the-error/72866>\
**Category:** Drivers & Stacks\
**Tags:** deadlock, javascript, locks, nodejs\
**Created:** [March 3, 2025, 2:02pm UTC](https://community.neo4j.com/t/unhandled-exclusivelock-exception-in-node-js-with-neo4j-5-26-1-unable-to-catch-the-error/72866 "2025-03-03T14:02:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nadavbi87](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/nadavbi87/32/23765_2.png) [@nadavbi87](https://community.neo4j.com/u/nadavbi87)\
**Post date:** [March 3, 2025, 2:02pm UTC](https://community.neo4j.com/t/unhandled-exclusivelock-exception-in-node-js-with-neo4j-5-26-1-unable-to-catch-the-error/72866/1 "2025-03-03T14:02:19Z")

</div>

Hi everyone,

I’m running a **highly concurrent** application that writes multiple **nodes and relationships** into **Neo4j Enterprise Edition 5.26.1** using the official **Neo4j Node.js driver 5.26**. The entire application is wrapped in a **try/catch** block, and I am **awaiting** all Neo4j write operations.

Whenever I encounter **Neo4j errors** like **Timeouts** or **Insufficient Memory** , I can catch them and handle retries accordingly. However, when a \*\* ExclusiveLock Exception\*\* occurs, I cannot catch it in my try/catch block. The only way I can detect it is through the **`unhandledRejection` event** in Node.js:

```auto
Unhandled Promise Rejection at: [object Promise], Reason:Neo4jError: ForsetiClient[transactionId=15157613, clientId=2396215] can't acquire ExclusiveLock{owner=ForsetiClient[transactionId=15157626, clientId=2396214]} on NODE(670236072) because holders of that lock are waiting for ForsetiClient[transactionId=15157613, clientId=2396215].
Wait list:ExclusiveLock[
Client[15157626] waits for [ForsetiClient[transactionId=15157613, clientId=2396215]]], Stack trace: Neo4jError: ForsetiClient[transactionId=15157613, clientId=2396215] can't acquire ExclusiveLock{owner=ForsetiClient[transactionId=15157626, clientId=2396214]} on NODE(670236072) because holders of that lock are waiting for ForsetiClient[transactionId=15157613, clientId=2396215].
Wait list:ExclusiveLock[
Client[15157626] waits for [ForsetiClient[transactionId=15157613, clientId=2396215]]]

at captureStacktrace (/usr/src/app/node_modules/.pnpm/neo4j-driver-core@5.26.0/node_modules/neo4j-driver-core/lib/result.js:624:17)
at new Result (/usr/src/app/node_modules/.pnpm/neo4j-driver-core@5.26.0/node_modules/neo4j-driver-core/lib/result.js:112:23)
at finishTransaction (/usr/src/app/node_modules/.pnpm/neo4j-driver-core@5.26.0/node_modules/neo4j-driver-core/lib/transaction.js:510:12)
at Object.commit (/usr/src/app/node_modules/.pnpm/neo4j-driver-core@5.26.0/node_modules/neo4j-driver-core/lib/transaction.js:323:25)
at Transaction.commit (/usr/src/app/node_modules/.pnpm/neo4j-driver-core@5.26.0/node_modules/neo4j-driver-core/lib/transaction.js:204:37)
at TransactionExecutor._handleTransactionWorkSuccess (/usr/src/app/node_modules/.pnpm/neo4j-driver-core@5.26.0/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:225:16)
at /usr/src/app/node_modules/.pnpm/neo4j-driver-core@5.26.0/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:201:42
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

```

Has anyone faced this issue before ?

---

<div class="post-metadata">

**Author:** ![max.gustafsson](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/max.gustafsson/32/32515_2.png) [@max.gustafsson](https://community.neo4j.com/u/max.gustafsson)\
**Post date:** [March 6, 2025, 8:25am UTC](https://community.neo4j.com/t/unhandled-exclusivelock-exception-in-node-js-with-neo4j-5-26-1-unable-to-catch-the-error/72866/2 "2025-03-06T08:25:26Z")

</div>

Hello @nadavbi87!

I am maintaining the Neo4j JS driver. I will be looking into your issue to see if there's something irregular being done with error handling for lock exceptions.

In the meantime, since I assume you are using `session.run()` for your queries, you can let driver itself to handle retry logic for retryable errors by using the `driver.executeQuery()` or `session.executeRead()/executeWrite()` methods.

---

<div class="post-metadata">

**Author:** ![max.gustafsson](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/max.gustafsson/32/32515_2.png) [@max.gustafsson](https://community.neo4j.com/u/max.gustafsson)\
**Post date:** [March 28, 2025, 12:19pm UTC](https://community.neo4j.com/t/unhandled-exclusivelock-exception-in-node-js-with-neo4j-5-26-1-unable-to-catch-the-error/72866/3 "2025-03-28T12:19:23Z")

</div>

Hi again @nadavbi87 !

I spent some time attempting to reproduce your issue, but I have not been able to. `session.run()` appears to correctly throw a catchable error, and the `driver.executeQuery()` or `session.executeRead()/executeWrite()` methods all correctly retry and handle deadlocks on their own.

If you have more information which you think might enable reproduction of your issue, please do reach out so that I can look further into it!
