Skip to content

Migrate project to Bun runtime #5

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

Merged
merged 1 commit into from
May 20, 2025

Conversation

arunavo4
Copy link
Collaborator

Summary

  • switch runtime to Bun and use native Bun SQLite
  • use Bun Redis client
  • update docs for Bun runtime
  • update build/test scripts for Bun

Testing

  • bun x vitest run

@arunavo4 arunavo4 requested a review from Copilot May 20, 2025 09:28
@arunavo4 arunavo4 added enhancement New feature or request and removed codex labels May 20, 2025
@arunavo4 arunavo4 self-assigned this May 20, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the project from Node.js to the Bun runtime by switching clients, drivers, scripts, and documentation.

  • Replace ioredis with Bun’s native RedisClient and adjust connection logic
  • Swap @libsql/client for Bun’s bun:sqlite, add a lightweight wrapper, and update Drizzle initialization
  • Update docs, package scripts, and engine definitions for Bun compatibility

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lib/redis.ts Swapped ioredis for Bun’s RedisClient and refactored event handling
src/lib/db/index.ts Replaced libSQL client with Bun’s SQLite API and wrapper; updated Drizzle import
src/content/docs/quickstart.md Changed runtime prerequisite to Bun 1.2.9+
src/content/docs/configuration.md Clarified NODE_ENV description
src/content/docs/architecture.md Updated backend runtime references to Bun
package.json Updated engines, scripts (bun/bunx), and removed unused deps
README.md Updated prerequisites and backend runtime to Bun
Comments suppressed due to low confidence (2)

src/lib/db/index.ts:18

  • The new SQLite wrapper’s execute method isn’t covered by tests. Adding unit tests for both read and write paths will help catch regressions and ensure correct behavior.
export const client = {

src/lib/db/index.ts:31

  • Drizzle is now initialized with the raw Bun SQLite instance instead of the wrapper client. Verify that this meets your parameter substitution and transaction needs—if not, consider passing the wrapper client to Drizzle.
export const db = drizzle(sqlite);

Comment on lines +11 to +23
return new RedisClient(redisUrl, {
autoReconnect: true,
});
}

export const redis = new Redis(redisUrl, redisOptions);
export const redisPublisher = new Redis(redisUrl, redisOptions); // For publishing
export const redisSubscriber = new Redis(redisUrl, redisOptions); // For subscribing
export const redis = createClient();
export const redisPublisher = createClient();
export const redisSubscriber = createClient();

// Log connection events
redis.on('connect', () => console.log('Redis client connected'));
redis.on('error', (err) => console.error('Redis client error:', err));
redis.on('ready', () => console.log('Redis client ready'));
redis.on('reconnecting', () => console.log('Redis client reconnecting...'));
redis.onconnect = () => console.log("Connected to Redis server");
redis.onclose = (err) => {
if (err) console.error("Disconnected from Redis server:", err);
};
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Event handlers are only attached to the primary Redis client, not to the publisher or subscriber. Consider registering common connection/error logging inside createClient so all instances receive consistent handling.

Copilot uses AI. Check for mistakes.


// Simple async wrapper around Bun's SQLite API for compatibility
export const client = {
async execute(sql: string, params?: any[]) {
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detection of SELECT queries via a simple regex could fail for SQL with leading comments or unusual whitespace. Consider separate read/write methods or a more robust strategy for distinguishing query types.

Copilot uses AI. Check for mistakes.

@arunavo4 arunavo4 marked this pull request as ready for review May 20, 2025 09:47
@arunavo4 arunavo4 merged commit e95f1d9 into bun May 20, 2025
0 of 2 checks passed
@arunavo4 arunavo4 deleted the ray/migrate-project-to-bun-with-redis-and-sqlite branch May 20, 2025 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant