Skip to content

Commit 140da44

Browse files
fix(workspace-events): skip no_activity subscriptions on the execution-completion path
no_activity is poller-owned and can never fire from a completed execution, but it passed into the rule branch and cost a pointless cooldown point-read per subscription on the hottest path. Early-continue alongside the workflow_deployed guard. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8a539f6 commit 140da44

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

apps/sim/lib/workspace-events/emitter.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,18 @@ describe('emitExecutionCompletedEvent', () => {
256256
})
257257
})
258258

259+
it('skips no_activity subscriptions before any cooldown read or rule evaluation (poller-owned)', async () => {
260+
const sub = makeSubscription(makeConfig({ eventType: 'no_activity' }))
261+
mockFetchSubscriptions.mockResolvedValueOnce([sub])
262+
263+
await emitExecutionCompletedEvent(makeLog())
264+
265+
expect(mockReadLastFiredAt).not.toHaveBeenCalled()
266+
expect(mockEvaluateRule).not.toHaveBeenCalled()
267+
expect(mockClaimCooldown).not.toHaveBeenCalled()
268+
expect(mockProcessPolledWebhookEvent).not.toHaveBeenCalled()
269+
})
270+
259271
it('skips rule evaluation while within the cooldown window', async () => {
260272
mockReadLastFiredAt.mockResolvedValueOnce(new Date())
261273
mockFetchSubscriptions.mockResolvedValueOnce([

apps/sim/lib/workspace-events/emitter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ export async function emitExecutionCompletedEvent(log: WorkflowExecutionLog): Pr
105105
const config = parseSubscriptionConfig(subscription.webhook.providerConfig)
106106
if (!config) continue
107107
if (config.eventType === 'workflow_deployed') continue
108+
// no_activity is owned by the inactivity poller and can never fire from
109+
// a completed execution; skip before the rule branch costs a cooldown
110+
// read on this hot path.
111+
if (config.eventType === 'no_activity') continue
108112

109113
if (subscription.webhook.workflowId === log.workflowId) continue
110114
if (!matchesWorkflowScope(config, log.workflowId)) continue

0 commit comments

Comments
 (0)