Closed sonicjhon1 closed 1 year ago
Hey 👋
In order to use surrealdb specific statements, you need to instantiate SurrealKysely
instead of Kysely
.
https://github.com/igalklebanov/kysely-surrealdb#surrealkysely-query-builder
Ah, yes that fixed the issue of not being able to call create 😁
But now it seems like it has frozen up 🤔 It doesn't crash nor does it connects to the database. The SurrealDB log stays the same, and no data in the database got updated.
I've updated the Minimal reproduction project again, https://github.com/sonicjhon1/kysely-surreal-error
Following up, after updating to "kysely-surrealdb": "^0.7.2"
, it doesn't freeze anymore but rather show the following error:
Error: connect ECONNREFUSED ::1:8000
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1532:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 8000
}
Updated minimal reproduction project here
This happens with SurrealDbHttpDialect
or SurrealDbWebSocketsDialect
.
I've made sure that:
pnpm i --force
I've cloned your repo, it's working against my local surrealdb docker container (I'm using this project's docker-compose file), and persists person:100
(can be retrieved later).
When using SurrealDbWebSocketsDialect
, you need to .destroy()
to close the connection when completing, otherwise, it hangs.
Do you know the address Surrealist uses to connect?
That ::1
(IPv6) is suspicious, might wanna explore that situation. Maybe surrealdb's image only supports IPv4. 🤷
Do you know the address Surrealist uses to connect?
I don't really know if it changes the address inputed inside of the app before connecting to the DB or not, but http://localhost:8080
or ws://localhost:8080
works in Surrealist.
That ::1 (IPv6) is suspicious, might wanna explore that situation. Maybe surrealdb's image only supports IPv4. 🤷
Right, it seems that instead of using localhost:8080
, using 127.0.0.1:8080
did fixed that problem (which I guess made it use IPv4 instead?). But even after using 127.0.0.1:8080
it still errors out with:
Error: write EPROTO FC630000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:355:
at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) {
errno: -4046,
code: 'EPROTO',
syscall: 'write'
}
Which then I found out why that's happening: https://github.com/igalklebanov/kysely-surrealdb/blob/e488dc2e08f8cddb6b07ab44842a0ccc6b63b884/src/dialect/shared.ts#LL4C7-L4C7
This line made everything that isn't localhost
use the https protocol, which means that 127.0.0.1
would also use the https protocol.
A simple fix is:
const protocol = (hostname.startsWith("localhost") || hostname.startsWith("127.0.0.1")) ? "http" : "https";
Released in v0.7.4.
Hello, its me again :) For some reason Typescript couldn't call create because for some reason that doesn't exist(?). Minimal reproduction project here: https://github.com/sonicjhon1/kysely-surreal-error The code is from the Readme.md example:
Also, the project above doesn't seem to do any connection to the DB even if I modified the code to not use create: