mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-09 03:17:54 +00:00
refactor(lbug): drop isDbBusyError re-export, import from lbug-config directly
The re-export from lbug-adapter.ts was a transitional convenience — with the matcher now living in lbug-config.ts, having two import paths for the same symbol invites future drift. Updated the two real consumers (lbug-lock-retry.test.ts, lbug-open-retry.test.ts) to import from lbug-config directly, removed the re-export equality test (now vacuous), and refreshed the explanatory comment so it no longer references a re-export pattern that doesn't exist. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e6924f31a7
commit
a96455afca
4 changed files with 6 additions and 17 deletions
|
|
@ -188,12 +188,6 @@ const DB_LOCK_RETRY_ATTEMPTS = 3;
|
|||
/** Base back-off in ms between BUSY retries (multiplied by attempt number). */
|
||||
const DB_LOCK_RETRY_DELAY_MS = 500;
|
||||
|
||||
/**
|
||||
* Re-exported from `lbug-config.ts` (single source of truth) so existing
|
||||
* importers continue to resolve `isDbBusyError` from this module.
|
||||
*/
|
||||
export { isDbBusyError };
|
||||
|
||||
/**
|
||||
* Return true when the error message indicates a write was attempted against
|
||||
* a read-only LadybugDB connection. The MCP query pool opens DBs read-only,
|
||||
|
|
|
|||
|
|
@ -62,11 +62,10 @@ export interface LbugConnectionHandle {
|
|||
* (`new lbug.Database(...)` raises from `local_file_system.cpp`) or during
|
||||
* a query (another writer holds the exclusive lock).
|
||||
*
|
||||
* Source of truth lives here so both the construction-time retry
|
||||
* (`openWithLockRetry`) and the query-time retry (`withLbugDb` in
|
||||
* `lbug-adapter.ts`) agree on the matcher. Other matchers (e.g.
|
||||
* `isReadOnlyDbError`) should follow this pattern: define here, re-export
|
||||
* from the adapter — see `references/findings-schema.json` adv-1 / maint-4.
|
||||
* Lives here (not in `lbug-adapter.ts`) so both the construction-time
|
||||
* retry (`openWithLockRetry` in this file) and the query-time retry
|
||||
* (`withLbugDb` in `lbug-adapter.ts`) consult the same matcher. Callers
|
||||
* import directly from this module — no re-export to keep in sync.
|
||||
*/
|
||||
export const isDbBusyError = (err: unknown): boolean => {
|
||||
const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { withTestLbugDB } from '../helpers/test-indexed-db.js';
|
|||
|
||||
// Pure-function tests — no DB needed, but grouped here for cohesion
|
||||
// with the retry logic they guard.
|
||||
import { isDbBusyError } from '../../src/core/lbug/lbug-adapter.js';
|
||||
import { isDbBusyError } from '../../src/core/lbug/lbug-config.js';
|
||||
|
||||
describe('isDbBusyError', () => {
|
||||
it('returns true for "busy" errors (case-insensitive)', () => {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import {
|
|||
openLbugConnection,
|
||||
waitForWindowsHandleRelease,
|
||||
} from '../../src/core/lbug/lbug-config.js';
|
||||
import * as adapterReexport from '../../src/core/lbug/lbug-adapter.js';
|
||||
|
||||
// ─── Minimal stub of the `lbug` module surface used by openLbugConnection ──
|
||||
|
||||
|
|
@ -51,10 +50,7 @@ const makeStubLbug = (control: StubModuleControl) => {
|
|||
return { Database: FakeDatabase, Connection: FakeConnection } as any;
|
||||
};
|
||||
|
||||
describe('isDbBusyError (re-exported source of truth)', () => {
|
||||
it('matcher in lbug-adapter is the same function as in lbug-config', () => {
|
||||
expect(adapterReexport.isDbBusyError).toBe(isDbBusyError);
|
||||
});
|
||||
describe('isDbBusyError', () => {
|
||||
it('matches the documented Windows lock-error wording', () => {
|
||||
expect(isDbBusyError(new Error('Could not set lock on file foo.lbug'))).toBe(true);
|
||||
expect(isDbBusyError(new Error('database is locked'))).toBe(true);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue