Closed gluax closed 1 month ago
I did attempt this with a try catch
block as well, but no ever was ever caught and it would still hang at the info
or any other execution method.
This issue does not affect the ExperimentalSurrealHTTP
this functions as normal :)
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 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.
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...
@kearfy Hey, I'm on Bun 0.7.3
, surreal 1.0.0-beta.9+20230820.b350f05
and surrealdb.js 0.8.4
and mine just hangs when connecting. You manage to find a fix?
*still the same on Bun 0.8.0
Bun 1.0 just released and still the same issue.
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.
const { ExperimentalSurrealHTTP } = require('surrealdb.js');
const db = new ExperimentalSurrealHTTP();
async function main() {
try {
await db.connect('http://127.0.0.1:8000/rpc', {});
// Select a specific namespace / database
await db.use({ns: 'test', db: 'test'});
// Create a new person with a random id
let created = await db.create("person", {
title: 'Founder & CEO',
name: {
first: 'Tobie',
last: 'Morgan Hitchcock',
},
marketing: true,
identifier: Math.random().toString(36).slice(2, 12),
});
// Update a person record with a specific id
let updated = await db.merge("person:jaime", {
marketing: true,
});
// Select all people records
let people = await db.select("person");
// Perform a custom advanced query
let groups = await db.query('SELECT marketing, count() FROM type::table($tb) GROUP BY marketing', {
tb: 'person',
});
console.log(people);
console.log(groups);
} catch (e) {
console.error('ERROR', e);
}
}
main();
For me, the one-shot connect method worked and the above separated signing/use did not.
import {ExperimentalSurrealHTTP} from 'surrealdb.js'
const surreal = new ExperimentalSurrealHTTP()
await surreal.connect('http://localhost:8000/rpc', {auth: {user: 'root', pass: 'root'}, ns: 'test', db: 'test'})
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
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.
This is now working for us in bun 1.0.15 as they have updated their websocket client
I tried yesterday and surreal.js it's working but surreal.node gave me error
@burakakca I recommend using surreal.js
surrealdb
package with websockets for Bun, I haven't run into any issues w/ it
@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?
Describe the bug
I'm running the following code with bun(version
0.7.0
)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?
Code of Conduct