Skip to content

Bug: RocksDB connection is still alive when db.close() is called #582

@hexadecimal233

Description

@hexadecimal233

Describe the bug

Currently, db.connect with rocksdb seems only works once.

If you try to connect db even after calling close, the program hangs.

and theres a new LOG file created in the db folder:

2026/03/15-21:20:42.389874 7e1c [WARN] [db/db_impl/db_impl_open.cc:2688] DB::Open() failed: IO error: Failed to create lock file: ./data/LOCK: 另一个程序正在使用此文件,进程无法访问。

It's kinda annoying if hot reloading enabled in such frameworks like nuxt and requires a full restart.

Possible causes

The file handles may not be correctly released and the instance wasn't fully freed in the surrealdb.

Steps to reproduce

minimal rerpo:

import { createNodeEngines } from "@surrealdb/node";
import { Surreal } from "surrealdb";

const db = new Surreal({
	engines: {
		...createNodeEngines(),
	},
});

await db.connect("rocksdb://./data");
console.log("1");
await db.close();
console.log("2");
await db.connect("rocksdb://./data");
console.log("3");
await db.close();
console.log("4");

output:

1
2

Expected behaviour

Can reconnect twitce in a single process.

SurrealDB version

3.0.3 Windows x64

JavaScript SDK version

2.0.2

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct (repository /surrealdb.js)

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions