π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix: enforce qstash minimum settling delay (#16926)
Arvin Xucdaef64bfaf5
diff --git a/.agents/skills/agent-testing/references/common-mistakes.md b/.agents/skills/agent-testing/references/common-mistakes.mdindex e87123ecaaa..1724044b40b 100644--- a/.agents/skills/agent-testing/references/common-mistakes.md+++ b/.agents/skills/agent-testing/references/common-mistakes.md@@ -368,3 +368,29 @@ primary left action replaced by a chevron/popup icon.the default state and the collapsed/overflow state. If the design requires aspecific action to stay visible, disable or bypass the toolbar collapse logic forthat surface and include evidence that no collapse chevron is rendered.++---++## Case 16 β Publishing a component harness when the user asked for full product verification++**Wrong approach**: when the isolated Electron instance failed once and local Docker+was unavailable, declaring the product-surface verification blocked and publishing a+component harness report as the main answer, even though another live Electron dev+pool / CDP route was already running and previous runs had used it successfully.++**Why it's wrong**: a component harness proves a narrow render contract, but it does+not prove the full product composition, message list layout, app theme tokens,+store plumbing, or that the evidence is inspectable in the actual desktop surface.+Environment friction is the agent-testing job to solve, not a reason to downgrade+without exhausting known running surfaces.++**What it breaks**: the user opens a report expecting complete product evidence and+gets a partial proof instead, then has to push back that the full verification used+to run normally.++**Correct approach**: before marking Electron/Web blocked, inventory existing dev+instances and CDP ports, check whether a sibling worktree already runs the needed+live branch, measure the target URL/bundle, and use that path if it renders current+code. Only keep a harness as supporting evidence; the primary UI evidence must come+from the product surface, or the report must clearly fail/block after every known+path is measured.diff --git a/apps/server/src/services/queue/__tests__/QueueService.test.ts b/apps/server/src/services/queue/__tests__/QueueService.test.tsindex dc50277dc51..71881721a7f 100644--- a/apps/server/src/services/queue/__tests__/QueueService.test.ts+++ b/apps/server/src/services/queue/__tests__/QueueService.test.ts@@ -169,14 +169,14 @@ describe('QueueService', () => {const impl = new QStashQueueServiceImpl({ qstashToken: 'test-qstash-token' });const result = impl.scheduleMessage({context: { phase: 'user_input' } as any,- delay: 50,+ delay: 500,endpoint: 'https://example.com/api/agent/run',operationId: 'op-test',priority: 'high',stepIndex: 0,});- await vi.advanceTimersByTimeAsync(49);+ await vi.advanceTimersByTimeAsync(499);expect(qstashMocks.publishJSON).not.toHaveBeenCalled();await vi.advanceTimersByTimeAsync(1);@@ -187,6 +187,33 @@ describe('QueueService', () => {expect(request.body.timestamp).toEqual(expect.any(Number));});+ it('should floor zero delay at the 300ms minimum settling window', async () => {+ vi.useFakeTimers();+ qstashMocks.publishJSON.mockResolvedValue({ messageId: 'msg-test' });++ const { QStashQueueServiceImpl } = await import('../impls/qstash');+ const impl = new QStashQueueServiceImpl({ qstashToken: 'test-qstash-token' });+ const result = impl.scheduleMessage({+ context: { phase: 'user_input' } as any,+ delay: 0,+ endpoint: 'https://example.com/api/agent/run',+ operationId: 'op-test',+ priority: 'high',+ stepIndex: 0,+ });++ // 300ms minimum β not yet published at 299ms+ await vi.advanceTimersByTimeAsync(299);+ expect(qstashMocks.publishJSON).not.toHaveBeenCalled();++ await vi.advanceTimersByTimeAsync(1);+ await expect(result).resolves.toBe('msg-test');++ // Zero delay is sub-second, so it is not forwarded to QStash+ const request = qstashMocks.publishJSON.mock.calls[0][0];+ expect(request).not.toHaveProperty('delay');+ });+it('should pass second-granularity delays through to QStash', async () => {qstashMocks.publishJSON.mockResolvedValue({ messageId: 'msg-test' });diff --git a/apps/server/src/services/queue/impls/qstash.ts b/apps/server/src/services/queue/impls/qstash.tsindex 8c88e957a78..582c271357c 100644--- a/apps/server/src/services/queue/impls/qstash.ts+++ b/apps/server/src/services/queue/impls/qstash.ts@@ -9,6 +9,17 @@ const log = debug('lobe-server:service:queue:qstash');const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));+/**+ * Minimum settling delay (ms) applied before publishing a QStash message.+ *+ * QStash's `delay` option is second-granularity β the `Duration` string form+ * (`10s`, `1m`, `2h`, `1d`) has no millisecond unit, and a bare number is+ * treated as seconds (so `100` would mean 100s, not 100ms). Sub-second settling+ * windows therefore cannot be delegated to QStash and must be honored locally;+ * this floors small or zero delays so a step always gets a brief settle.+ */+const MIN_SETTLING_DELAY_MS = 300;+const toQStashDelaySeconds = (delayMs: number): number | undefined => {if (delayMs <= 0) return undefined;if (delayMs < 1000) return undefined;@@ -45,11 +56,12 @@ export class QStashQueueServiceImpl implements QueueServiceImpl {try {// QStash publish delays are second-granularity (`10s`, `1m`, or numeric- // seconds). Preserve the runtime's small settling windows, such as the- // initial 50ms, by waiting before publishing instead of collapsing them to- // immediate delivery.- if (delay > 0 && delay < 1000) {- await sleep(delay);+ // seconds) and cannot express sub-second settling, so honor small windows+ // locally. Floor at MIN_SETTLING_DELAY_MS so even a zero/near-zero delay+ // still settles before publishing instead of collapsing to immediate+ // delivery.+ if (delay < 1000) {+ await sleep(Math.max(delay, MIN_SETTLING_DELAY_MS));}log('Initialized QStash queue service');