Closed dodanex closed 2 months ago
The Nuxt project was working fine under surrealdb.js@0.11.1
, but when I upgraded to the latest surrealdb.js@1.0.0-beta.5
, I encountered an issue. The error message is as follows:
dev: ERROR [nitro] [unhandledRejection] There is no connection available at this moment.
dev:
dev: at HttpEngine.rpc (node_modules/.pnpm/surrealdb.js@1.0.0-beta.5/node_modules/surrealdb.js/src/library/engine.ts:315:10)
dev: at runNextTicks (node:internal/process/task_queues:60:5)
dev: at listOnTimeout (node:internal/timers:540:9)
dev: at process.processTimers (node:internal/timers:514:7)
dev: at Surreal.ping (node_modules/.pnpm/surrealdb.js@1.0.0-beta.5/node_modules/surrealdb.js/src/surreal.ts:160:21)
dev: ERROR [nitro] [unhandledRejection] There is no connection available at this moment.
dev:
dev: at HttpEngine.rpc (node_modules/.pnpm/surrealdb.js@1.0.0-beta.5/node_modules/surrealdb.js/src/library/engine.ts:315:10)
dev: at Surreal.ping (node_modules/.pnpm/surrealdb.js@1.0.0-beta.5/node_modules/surrealdb.js/src/surreal.ts:160:21)
I noticed that the client connection method in the documentation remains the same. I'm not sure if it's a compatibility issue with other dependencies.
Steps to reproduce pnpm update surrealdb.js
Expected behaviour The project was working fine under surrealdb.js@1.0.0-beta.5
Hey @dodanex and @gtwww, could you both share how you initiate the connection to SurrealDB with the library? I'll see if I'm able to reproduce this issue
@kearfy I just followed the documentation to connect to SurrealDB. I'm also using Nuxt.js v3. Keep in mind that the same code is working with v0.11.1 but not in beta5!
import { Surreal } from 'surrealdb.js'
export const db = new Surreal()
export default defineNitroPlugin(async () => {
try {
const config = useRuntimeConfig()
await db.connect(config.DB_URL)
await db.signin({
username: config.DB_USER,
password: config.DB_PASSWORD,
namespace: config.DB_NAMESPACE,
database: config.DB_NAME
})
console.info('<===[ SurrealDB is Connected! ]===>')
} catch (error) {
throw new Error(error as unknown as string)
}
})
@kearfy @dodanex Got it! Changing the connection url from http://localhost:8000/rpc
to ws://localhost:8000
it's working fine now.
@kearfy I confirm that changing from http
to ws
I'm now able to connect to the database.
Thank you!
Ah! It should still work via HTTP aswell however 🤔 I'll reopen and adjust the title for the moment, need to investigate why that is happening... Thanks!
Describe the bug
Using v1.0.0-beta.5 I got this error:
ConnectionUnavailable: There is no connection available at this moment.
But after switching back to v0.11.1 it works fine.
Edit from maintainer: In the previous SDK, the class you used decided which protocol you would connect over, meaning http would get "corrected" to websocket. There seems to be an issue with the HTTP engine, need to investigate what is going on there.
Steps to reproduce
Use the v1.0.0-beta.5 and try to connect to the database.
Expected behaviour
To work as expected.
SurrealDB version
1.4.2
SurrealDB.js version
1.0.0-beta.5
Is there an existing issue for this?
Code of Conduct