surrealdb.js: Bug: Not working with Bun?
Describe the bug
I’m running the following code with bun(version 0.7.0)
import { Surreal } from 'surrealdb.js';
console.log("foo");
const db = new Surreal('http://127.0.0.1:8000/rpc', {
// Set the namespace and database for the connection
ns: 'test',
db: 'test',
// Set the authentication details for the connection
auth: {
user: 'root',
pass: 'root',
},
});
await db.info();
console.log("bar"); //this is never hit
The surrealdb logs are as follows:
Steps to reproduce
Install bun. Install surrealdb bun add surrealdb.js surreal start --log trace --user root --pass root memory copy the minimal example to file bun run index.ts
Expected behaviour
To be able to connect to the DB from typescript within Bun.
SurrealDB version
1.0.0-beta.9+20230402.5eafebd for linux on x86_6
SurrealDB.js version
^0.8.3
Contact Details
No response
Is there an existing issue for this?
- I have searched the existing issues
Code of Conduct
- I agree to follow this project’s Code of Conduct
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 12
- Comments: 15 (2 by maintainers)
https://github.com/oven-sh/bun/issues/5434
This is a bug in Bun, not surrealdb. Our WebSocket client has some issues. We should open a tracking issue in Bun’s repo so we don’t forget about it though.
For me, the one-shot connect method worked and the above separated signing/use did not.
This is now working for us in bun 1.0.15 as they have updated their websocket client
Hey everyone, as per the bun docs, their websocket implementation is still experimental and it does not properly pass all test suites. The broken pipe error is something that the JS side of things does not influence and really rather is an issue in Bun’s websocket implementation. I’m afraid I can’t make it any better for the moment! Will leave the issue open however
Hi @gluax, we actually run tests against bun. The only known issue there is that the awaiting the closing of the websocket will run forever, looking into that soon. Will also have a look at this, it should work just fine…
I looked at the source code, and it seems the experimental http version works with Bun run! There’s no documentation on it, but something like this should work.
Bun 1.0 just released and still the same issue.
@kearfy Hey, I’m on
Bun 0.7.3,surreal 1.0.0-beta.9+20230820.b350f05andsurrealdb.js 0.8.4and mine just hangs when connecting. You manage to find a fix?*still the same on
Bun 0.8.0I have a similar issue when using Bun, I get
2023-08-22 22:30:08 2023-08-22T20:30:08.902561Z TRACE surrealdb::net: RPC Received: { id: '1259', method: 'ping', params: [] } ](surrealdb::net: WebSocket error: Io(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }))and my promise from, the operation waits infinity. However, the same code using node works peferkt.@kearfy This is good to close isn’t it unless there’s more issues with surrealdb.js on bun?
If its a issue with surreal.node then that should be in the https://github.com/surrealdb/surrealdb.node repo?
@burakakca I recommend using
surreal.jssurrealdbpackage with websockets for Bun, I haven’t run into any issues w/ it