Troubleshooting Guide
Solutions to common issues when using bunqueue.
Installation Issues
”bunqueue requires Bun runtime”
bunqueue only works with Bun, not Node.js.
# Check if Bun is installedbun --version
# Install Bun if neededcurl -fsSL https://bun.sh/install | bashPermission errors on install
# Try with sudo (not recommended)sudo bun add bunqueue
# Better: fix npm permissionsmkdir ~/.bunchown -R $(whoami) ~/.bunDatabase Issues
”SQLITE_BUSY: database is locked”
Multiple processes trying to write simultaneously.
Solutions:
- Use WAL mode (default in bunqueue)
- Ensure only one server instance per database file
- Use server mode for multi-process access
# Check for multiple processeslsof ./data/queue.db
# Kill stale processespkill -f bunqueue”SQLITE_CORRUPT: database disk image is malformed”
Database corruption, usually from crash during write.
Solutions:
- Restore from S3 backup
- Delete and recreate database (data loss)
# Restore from backupbunqueue backup listbunqueue backup restore <key> --force
# Or recreate (loses data)rm ./data/queue.db*bunqueue startDatabase file keeps growing
SQLite doesn’t automatically reclaim space.
# Vacuum the database (run when server is stopped)sqlite3 ./data/queue.db "VACUUM;"
# Enable auto-vacuum (before creating database)sqlite3 ./data/queue.db "PRAGMA auto_vacuum = INCREMENTAL;"Embedded Mode Issues
”Command timeout” error
error: Command timeout queue: "my-queue", context: "pull"This error means your Worker is trying to connect to a TCP server instead of using embedded mode.
Solution: Add embedded: true to both Queue and Worker:
// WRONG - Worker defaults to TCP modeconst queue = new Queue('tasks', { embedded: true });const worker = new Worker('tasks', processor); // Missing embedded: true!
// CORRECT - Both have embedded: trueconst queue = new Queue('tasks', { embedded: true });const worker = new Worker('tasks', processor, { embedded: true });SQLite database not created
The database is only created when DATA_PATH is set.
Solution:
// Set DATA_PATH BEFORE importing bunqueueimport { mkdirSync } from 'fs';mkdirSync('./data', { recursive: true });process.env.DATA_PATH = './data/bunqueue.db';
// Then importimport { Queue, Worker } from 'bunqueue/client';Jobs not persisted across restarts
If you’re using multiple files, the Worker’s autorun: true (default) can cause the QueueManager to initialize before DATA_PATH is set.
Solution: Use autorun: false and start the worker manually:
const worker = new Worker('tasks', processor, { embedded: true, autorun: false, // Don't start automatically});
export function startWorker() { worker.run();}process.env.DATA_PATH = './data/bunqueue.db';
import { startWorker } from './queue';startWorker(); // Start after DATA_PATH is setJob Processing Issues
Jobs stuck in “active” state
Worker crashed while processing.
Solutions:
- Enable stall detection
- Restart workers
queue.setStallConfig({ enabled: true, stallInterval: 30000, maxStalls: 3,});Jobs not being processed
Check these:
- Is the queue paused?
- Is there a worker for this queue?
- Is rate limiting blocking jobs?
// Check if pausedconst isPaused = queue.isPaused();
// Check countsconst counts = queue.getJobCounts();console.log(counts);
// Check rate limitconst config = queue.getRateLimit();Jobs failing immediately
Check the error in failed event:
worker.on('failed', (job, error) => { console.error('Job failed:', error); console.error('Job data:', job.data); console.error('Attempts:', job.attemptsMade);});Memory usage keeps growing
Possible causes:
- Jobs not being removed after completion
- Too many jobs in DLQ
- Memory leak in processor
// Enable removeOnCompleteawait queue.add('task', data, { removeOnComplete: true,});
// Purge old DLQ entriesqueue.purgeDlq();
// Check for leaks in processorworker.on('completed', () => { console.log('Memory:', process.memoryUsage().heapUsed);});Connection Issues
”Connection refused” to server
Server not running or wrong port.
# Check if server is runningps aux | grep bunqueue
# Check listening portslsof -i :6789lsof -i :6790
# Start serverbunqueue startTCP connection drops
Network issues or server overload.
// Add reconnection logiclet client = createClient();
client.on('error', async () => { await sleep(1000); client = createClient();});Authentication failures
# Check token is setecho $AUTH_TOKENS
# Test with curlcurl -H "Authorization: Bearer your-token" \ http://localhost:6790/healthPerformance Issues
Slow job processing
Optimize:
- Increase worker concurrency
- Use batch operations
- Check database I/O
// Increase concurrencyconst worker = new Worker('queue', processor, { concurrency: 20,});
// Use bulk addawait queue.addBulk([...jobs]);
// Use bulk ackawait queue.ackBatch([...jobIds]);High latency on pull
Check:
- Index on queue table
- Too many delayed jobs
- Database on slow disk
-- Check indexes exist.indices jobs
-- Check delayed jobs countSELECT COUNT(*) FROM jobs WHERE state = 'delayed';Server CPU at 100%
Too many connections or jobs.
# Check connection countbunqueue stats
# Reduce polling frequency# Add backoff in clientsBackup Issues
S3 backup failing
# Check credentialsecho $S3_ACCESS_KEY_IDecho $S3_BUCKET
# Test connectivityaws s3 ls s3://$S3_BUCKET/
# Check logsbunqueue backup statusRestore failing
# List available backupsbunqueue backup list
# Force restore (overwrites existing)bunqueue backup restore <key> --forceSandboxed Worker Issues
Segmentation fault when terminating workers
If you experience crashes (segfaults) when using SandboxedWorker, especially during worker timeout or error handling, this is a known Bun bug.
Symptoms:
Segmentation fault at address 0xE8Worker has been terminatederrors- Crashes during
worker.terminate()calls
Workaround:
- Avoid forcefully terminating workers when possible
- Use graceful shutdown instead of
worker.terminate() - Consider using the standard
Workerclass instead ofSandboxedWorkerfor production workloads
// Instead of force terminationawait worker.stop(); // Graceful shutdown
// Avoid tight timeout values that cause frequent terminationsconst worker = new SandboxedWorker('queue', { processor: './processor.ts', timeout: 30000, // Use longer timeout to avoid frequent terminations});This issue will be resolved in a future Bun release.
Common Error Messages
| Error | Cause | Solution |
|---|---|---|
Command timeout | Worker missing embedded: true | Add embedded: true to Worker options |
SQLITE_BUSY | Database locked | Use single writer |
SQLITE_FULL | Disk full | Free disk space |
ECONNREFUSED | Server not running | Start server or use embedded mode |
ETIMEDOUT | Network issue | Check connectivity |
Job not found | Already completed/removed | Check job lifecycle |
Segmentation fault | Bun Worker termination bug | Use graceful shutdown, see above |
Debug Mode
Enable verbose logging:
# Server modeLOG_FORMAT=json DEBUG=bunqueue:* bunqueue start
# Check logstail -f /var/log/bunqueue.logGetting Help
If these solutions don’t help:
- Check GitHub Issues
- Search Discussions
- Open a new issue with:
- bunqueue version
- Bun version
- OS and hardware
- Error message and stack trace
- Minimal reproduction code