Complete list of errors thrown or emitted by OmniDB.
| Error Message | Thrown By | Cause |
|---|---|---|
Connection "X" is unavailable |
execute() |
Circuit open or connection not found |
Circuit breaker is OPEN |
CircuitBreaker.execute() |
Circuit in open state |
Circuit open for "X" |
get() (emitted) |
Circuit prevents access |
Config must be an object |
Orchestrator constructor |
Invalid config |
Config must include a connections object |
Orchestrator constructor |
Missing connections |
At least one connection must be provided |
Orchestrator constructor |
Empty connections |
Name must be a non-empty string |
Registry.register() |
Invalid name |
Client must not be null or undefined |
Registry.register() |
Invalid client |
await db.execute('primary', fn);
// Error: Connection "primary" is unavailableCause: The circuit breaker for this connection is open.
Solution: Handle circuit-open gracefully:
try {
await db.execute('primary', fn);
} catch (err) {
if (err.message.includes('unavailable')) {
// Use fallback, return cached data, etc.
}
}try {
db.get('primary');
} catch (err) {
// err.message: 'Circuit open for "primary"'
}Cause: Called get() while circuit is open.
Note: get() throws this error immediately. You should catch it or use execute().
const circuit = new CircuitBreaker({ threshold: 3 });
// After 3 failures...
await circuit.execute(fn);
// Error: Circuit breaker is OPENCause: Too many failures caused the circuit to open.
Solution: Wait for resetTimeout (default 30s) for half-open state, or handle the error:
try {
return await circuit.execute(fn);
} catch (err) {
if (err.message === 'Circuit breaker is OPEN') {
return cachedResult;
}
throw err;
}These are thrown immediately when creating an Orchestrator:
| Error | Fix |
|---|---|
Config must be an object |
Pass { connections: {...} } |
Config must include a connections object |
Add connections property |
At least one connection must be provided |
Add at least one connection |
registry.register('', client); // Error
registry.register(123, client); // Errorregistry.register('db', null); // Error
registry.register('db', undefined); // ErrorThe Orchestrator emits these error-related events:
db.on('error', (error) => {
console.error('Error:', error.message);
});
db.on('circuit:open', ({ name, reason, timestamp }) => {
// reason: 'health-check-failed' or undefined (threshold reached)
});
db.on('health:changed', ({ name, previous, current, timestamp }) => {
if (current === 'unhealthy') {
console.warn(`${name} is unhealthy`);
}
});try {
const result = await db.execute('primary', fn);
return result;
} catch (err) {
if (err.message.includes('unavailable')) {
return fallback();
}
throw err;
}db.on('circuit:open', ({ name }) => {
alertOpsTeam(`Circuit open for ${name}`);
});
db.on('error', (err) => {
logger.error(err);
});const stats = db.getStats();
if (stats.primary.circuit === 'open') {
return cachedData;
}
return await db.execute('primary', fn);