neo4j / neo4j-javascript-driver

Neo4j Bolt driver for JavaScript
https://neo4j.com/docs/javascript-manual/current/
Apache License 2.0
854 stars 148 forks source link

{ Neo4jError: Pool is closed, it is no more able to serve requests. #676

Closed ali-hasnain closed 3 years ago

ali-hasnain commented 3 years ago

neo4j-driver version 4.2.2 Neo4j Browser version: 4.2.0 Neo4j Server version: 4.1.5 (enterprise)

{ Neo4jError: Pool is closed, it is no more able to serve requests. at captureStacktrace (/workspace/node_modules/neo4j-driver/lib/result.js:281:15) at new Result (/workspace/node_modules/neo4j-driver/lib/result.js:68:19) at Session._run (/workspace/node_modules/neo4j-driver/lib/session.js:174:14) at Session.run (/workspace/node_modules/neo4j-driver/lib/session.js:135:19)

bigmontz commented 3 years ago

Hi @ali-hasnain,

could you share a small code snippet which result to this error?

Many thanks.

bigmontz commented 3 years ago

Hi @ali-hasnain,

Does this issue still occur?

Thanks.

bigmontz commented 3 years ago

Close due inactivity

ajmeese7 commented 1 year ago

I can attest that this is still an issue, the problem occurs for me whenever I've had to forcefully shut down and restart pnpm run dev a few times on my Svelte application. Whenever an application ins't closed gracefully, the connections aren't automatically killed, so the threshold for the maximum number of concurrent connections seems to be met.

Here is my full error log:

Neo4jError: Pool is closed, it is no more able to serve requests.

    at captureStacktrace (my-path/node_modules/.pnpm/neo4j-driver-core@5.3.0/node_modules/neo4j-driver-core/lib/result.js:611:17)
    at new Result (my-path/node_modules/.pnpm/neo4j-driver-core@5.3.0/node_modules/neo4j-driver-core/lib/result.js:105:23)
    at Session._run (my-path/node_modules/.pnpm/neo4j-driver-core@5.3.0/node_modules/neo4j-driver-core/lib/session.js:223:16)
    at Session.run (my-path/node_modules/.pnpm/neo4j-driver-core@5.3.0/node_modules/neo4j-driver-core/lib/session.js:174:27)
    at Module.runQuery (/src/routes/api/_runQuery.ts:8:17)
    at getNodes (my-path/src/routes/api/getNodes/+server.ts:7:48)
    at GET (my-path/src/routes/api/getNodes/+server.ts:17:26)
    at render_endpoint (file://my-path/node_modules/.pnpm/@sveltejs+kit@1.0.0-next.567_svelte@3.53.1+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/server/endpoint.js:45:26)
    at resolve (file://my-path/node_modules/.pnpm/@sveltejs+kit@1.0.0-next.567_svelte@3.53.1+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/server/index.js:362:23)
    at runMicrotasks (<anonymous>) {
  constructor: [Function: Neo4jError] { isRetriable: [Function (anonymous)] },
  code: 'N/A',
  retriable: false
}
JoshuaAmaju commented 1 year ago

I can attest that this is still an issue, the problem occurs for me whenever I've had to forcefully shut down and restart pnpm run dev a few times on my Svelte application. Whenever an application ins't closed gracefully, the connections aren't automatically killed, so the threshold for the maximum number of concurrent connections seems to be met.

Here is my full error log:

Neo4jError: Pool is closed, it is no more able to serve requests.

    at captureStacktrace (my-path/node_modules/.pnpm/neo4j-driver-core@5.3.0/node_modules/neo4j-driver-core/lib/result.js:611:17)
    at new Result (my-path/node_modules/.pnpm/neo4j-driver-core@5.3.0/node_modules/neo4j-driver-core/lib/result.js:105:23)
    at Session._run (my-path/node_modules/.pnpm/neo4j-driver-core@5.3.0/node_modules/neo4j-driver-core/lib/session.js:223:16)
    at Session.run (my-path/node_modules/.pnpm/neo4j-driver-core@5.3.0/node_modules/neo4j-driver-core/lib/session.js:174:27)
    at Module.runQuery (/src/routes/api/_runQuery.ts:8:17)
    at getNodes (my-path/src/routes/api/getNodes/+server.ts:7:48)
    at GET (my-path/src/routes/api/getNodes/+server.ts:17:26)
    at render_endpoint (file://my-path/node_modules/.pnpm/@sveltejs+kit@1.0.0-next.567_svelte@3.53.1+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/server/endpoint.js:45:26)
    at resolve (file://my-path/node_modules/.pnpm/@sveltejs+kit@1.0.0-next.567_svelte@3.53.1+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/server/index.js:362:23)
    at runMicrotasks (<anonymous>) {
  constructor: [Function: Neo4jError] { isRetriable: [Function (anonymous)] },
  code: 'N/A',
  retriable: false
}

Mine was because I was calling close on the driver instead of the session.

ajmeese7 commented 1 year ago

@JoshuaAmaju That'll definitely do it! I made sure to only close the drivers on program exit:

// Close the connection when the app stops
process.on("exit", async (code) => {
    await driver.close();
});
process.on("SIGINT", async () => {
    await driver.close();
});