fix(openclaw): add warn log and tests for CLI mode no-op in waitForReady (#799)
Follow-up to #764. Upgrades the silent debug log in waitForReady to log.warn so unexpected calls before service.start() are visible, and adds tests covering the CLI mode no-op path.
This commit is contained in:
parent
41025c3b7c
commit
d3d2684b11
2 changed files with 21 additions and 1 deletions
|
|
@ -425,3 +425,23 @@ describe('truncateRecallQuery', () => {
|
||||||
expect(truncated.length).toBeLessThanOrEqual(180);
|
expect(truncated.length).toBeLessThanOrEqual(180);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// waitForReady — CLI mode no-op (initPromise is null before service.start())
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
describe('waitForReady (CLI mode)', () => {
|
||||||
|
it('returns without error when initPromise is null (service.start not called)', async () => {
|
||||||
|
// The module sets up global.__hindsightClient on import.
|
||||||
|
// In test context, service.start() is never called so initPromise remains null.
|
||||||
|
const hindsight = (global as any).__hindsightClient;
|
||||||
|
expect(hindsight).toBeDefined();
|
||||||
|
// Should resolve without throwing
|
||||||
|
await expect(hindsight.waitForReady()).resolves.toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getClient returns null when service.start not called', () => {
|
||||||
|
const hindsight = (global as any).__hindsightClient;
|
||||||
|
expect(hindsight.getClient()).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ if (typeof global !== 'undefined') {
|
||||||
// If initPromise is null, it means service.start() hasn't been called yet
|
// If initPromise is null, it means service.start() hasn't been called yet
|
||||||
// (CLI mode, not gateway mode). Hooks should gracefully no-op.
|
// (CLI mode, not gateway mode). Hooks should gracefully no-op.
|
||||||
if (!initPromise) {
|
if (!initPromise) {
|
||||||
debug('[Hindsight] waitForReady called but initPromise is null (gateway not started)');
|
log.warn('waitForReady called before service.start() — hooks will no-op (expected in CLI mode)');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue