Replit Database: Undeletable Keys Bug

Problem description:
Using the current version of the replit’s database package you can create undeletable keys.

Expected behavior:

client.empty();

Deletes all keys from the database.

Actual behavior:
It doesn’t delete keys with a newline in them.

Steps to reproduce:

  1. Create a new repl
  2. Import the replit database package:
const Client = require("@replit/database");
const client = new Client();
  1. Create a an iife function so we can use async/await:
(async () => {
// Code goes here
})();
  1. Fill the function:
(async () => {
 	// create a new key
	await client.set("another\nnew\nline\n", "key");

 	// empty db
	await client.empty();

 	// get all keys
	const db = await client.getAll();

 	// So now the db must be empty, right... Right?
	console.log(db);
})();

And tada:
image

You can run the code here.

Solution:
I created a pull request which fixes the issue and also drastically improves code performance as seen here:

You can run the comparison here.

2 Likes

Hey @7heMech!

I was able to reproduce this and have sent this to the team. I will follow up as soon as I have an update!

3 Likes