Skip to content
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

db.ready() throws error #8

Open
MuhammedHalid opened this issue Mar 9, 2023 · 0 comments
Open

db.ready() throws error #8

MuhammedHalid opened this issue Mar 9, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@MuhammedHalid
Copy link

Describe the bug
db.ready() throws the following error:

He {
  type: 'error',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 3265.9472999982536
}

Example

// src/lib/server/db.ts
import { Cirql } from 'cirql';

import {
    SURREALDB_NS,
    SURREALDB_DB,
    SURREALDB_URL,
    SURREALDB_USER,
    SURREALDB_PASS,
} from "$env/static/private";
import { dev } from '$app/environment';
import { log } from '$lib/logger';
//import { withTimeout } from '$lib/utils';

declare global {
    var surrealdb: Cirql
}

export let db = global.surrealdb;
export async function conectDB() {
    if (db) return;
    log.warn('creating new connection to db!');
    try {
        db = new Cirql({
            connection: {
                endpoint: SURREALDB_URL,
                namespace: SURREALDB_NS,
                database: SURREALDB_DB,
            },
            credentials: {
                user: SURREALDB_USER,
                pass: SURREALDB_PASS,
            }
        });
        await db.ready();
        // await withTimeout(db.ready(), 'db connection timed out', 5000);
        if (dev) global.surrealdb = db;
        log.info('db connected ');
    } catch (error) {
        log.error('connecting to db:', error);
    }
}

Expected behavior
for that to not err out ig hands 🤷‍♂️

Environment:

  • OS: Windows
  • Version: 0.6.6
  • Node Version: v18.12.1
@MuhammedHalid MuhammedHalid added the bug Something isn't working label Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant