Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection attempts time out when connecting using Bun #1140

Open
Giant-Jelly opened this issue Sep 11, 2023 · 7 comments
Open

Connection attempts time out when connecting using Bun #1140

Giant-Jelly opened this issue Sep 11, 2023 · 7 comments

Comments

@Giant-Jelly
Copy link

It looks like when running the neo4j driver with bun (bun index.ts or bun index.js ) the connection to the database times out. But when running with node (node index.js) it connects fine.

Here is my index.js

import neo4j from "neo4j-driver-lite";
import 'dotenv/config'

async function main() {
    const NEO4J_URI = process.env.NEO4J_URI || "";
    const NEO4J_USERNAME = process.env.NEO4J_USERNAME || "";
    const NEO4J_PASSWORD = process.env.NEO4J_PASSWORD || "";

    console.log(NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD);
    const driver = neo4j.driver(NEO4J_URI, neo4j.auth.basic(NEO4J_USERNAME, NEO4J_PASSWORD));

    const serverInfo = await driver.getServerInfo();
    console.log(serverInfo);
}

main()

Output from bun index.js

 */
73 |     function Neo4jError(message, code, cause) {
74 |         var _this =
75 |         // eslint-disable-next-line
76 |         // @ts-ignore: not available in ES6 yet
77 |         _super.call(this, message, cause != null ? { cause: cause } : undefined) || this;
            ^
Neo4jError: Connection acquisition timed out in 60000 ms. Pool status: Active conn count = 0, Idle conn count = 0.
 code: "N/A"

output from node index.js


ServerInfo {
  address: '<ommitted>.databases.neo4j.io:7687',
  agent: 'Neo4j/5.11-aura',
  protocolVersion: 5.3
}

Node version v20.3.1
Bun version 1.0.0
Driver version: Latest
Neo4j version: Latest

Same behaviour with neo4j-driver and neo4j-driver-lite

Is this already a known issue? I feel like if it was because the driver is using something in node that is not supported by Bun that there would be an error instead of a timeout.

@bigmontz
Copy link
Contributor

Hey @Giant-Jelly, thanks for reporting.

This driver has not support for Bun yet.

I will register the request in our internally and I will keep this thread issue updated.

@bigmontz
Copy link
Contributor

The problem with Bun happens when use SSL (neo4j+s and bolt+s). The root cause of the issue is lack of full support to tls and crypto. See, `https://bun.sh/docs/runtime/nodejs-apis#node-crypto and https://bun.sh/docs/runtime/nodejs-apis#node-tls.

Driver's Websocket channel implementation works fine in most of the cases, but this still pending more extensive tests.

@thecoldstone
Copy link

Has it not been fixed yet?

@bigmontz
Copy link
Contributor

This feature stills depending on Bun implements crypto and TLS. WebSockets is not production ready either, see https://bun.sh/docs/runtime/web-apis.

@bigmontz
Copy link
Contributor

You can also import the driver like this:

import neo4j from 'neo4j-driver/lib/browser/neo4j-web.esm.js'

and use the browser version of the driver.

It will might work for most of the cases, but I don't consider this production ready since WebSocket is not production ready in Bun and we don't have test suite for this. So, this is a non supported feature.

@GuiBibeau
Copy link

@bigmontz does the browser substitute sockets for fetch calls?

The browser version does work well in bun but I would like to know the tradeoffs when it comes to using only the browser version

@bigmontz
Copy link
Contributor

bigmontz commented Jan 8, 2024

The browser version uses WebSockets instead of TCP Sockets. This causes performance losses, especially when creating and closing connections.

PS: This usage is not homologated by integration and acceptance tests, also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants