Files
bun.sh/test/js/valkey/valkey.connecting.fixture.ts
Ciro Spaciari 84f94ca6dd fix(Bun.RedisClient) keep it alive when connecting (#23195)
### What does this PR do?
Fixes https://github.com/oven-sh/bun/issues/23178
Fixes https://github.com/oven-sh/bun/issues/23187
Fixes https://github.com/oven-sh/bun/issues/23198
### How did you verify your code works?
Test

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-10-02 18:50:05 -07:00

29 lines
558 B
TypeScript

import { RedisClient } from "bun";
function getOptions() {
if (process.env.BUN_VALKEY_TLS) {
const paths = JSON.parse(process.env.BUN_VALKEY_TLS);
return {
tls: {
key: Bun.file(paths.key),
cert: Bun.file(paths.cert),
ca: Bun.file(paths.ca),
},
};
}
return {};
}
{
const client = new RedisClient(process.env.BUN_VALKEY_URL, getOptions());
client
.connect()
.then(redis => {
console.log("connected");
client.close();
})
.catch(err => {
console.error(err);
});
}