-
Notifications
You must be signed in to change notification settings - Fork 45
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
Bug: Not working with Bun? #159
Comments
I did attempt this with a |
This issue does not affect the |
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 |
@kearfy Hey, I'm on *still the same on |
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! 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 |
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
The text was updated successfully, but these errors were encountered: