Skip to content

Commit 6feaafe

Browse files
committed
fix(logs): keep a unique request id per webhook poll and per emitted event
Executions started by one poll tick, or by one parent request, would otherwise share a request id, and tool code that keys idempotency on it (deployments) could replay one execution's result in another. The logger now owns requestId on the line, so these ids no longer need to match the request to correlate.
1 parent 85b57ea commit 6feaafe

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎apps/sim/lib/webhooks/polling/orchestrator.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createLogger } from '@sim/logger'
2+
import { generateShortId } from '@sim/utils/id'
23
import { withResourceOutboundScope } from '@/lib/core/network/resource-scope.server'
3-
import { generateRequestId } from '@/lib/core/utils/request'
44
import { findRecentlyRefusedWorkspaces } from '@/lib/webhooks/polling/admission-refusals'
55
import { getPollingHandler } from '@/lib/webhooks/polling/registry'
66
import type { PollSummary } from '@/lib/webhooks/polling/types'
@@ -47,12 +47,11 @@ export async function pollProvider(providerName: string): Promise<PollSummary> {
4747
return 'skipped'
4848
}
4949

50-
// Polls share the tick's request id; the webhook id tells concurrent polls apart.
5150
return withResourceOutboundScope({ workspaceId: entry.workflow.workspaceId }, () =>
5251
handler.pollWebhook({
5352
webhookData: entry.webhook,
5453
workflowData: entry.workflow,
55-
requestId: generateRequestId(),
54+
requestId: generateShortId(),
5655
logger: logger.withMetadata({ webhookId: entry.webhook.id }),
5756
})
5857
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { getActiveWorkflowContext } from '@sim/platform-authz/workflow'
3-
import { generateRequestId } from '@/lib/core/utils/request'
3+
import { generateShortId } from '@sim/utils/id'
44
import type { WorkflowExecutionLog } from '@/lib/logs/types'
55
import {
66
isSimRuleEventType,
@@ -46,7 +46,7 @@ export async function dispatchSimEvent(
4646
subscription: SimSubscription,
4747
payload: SimEventPayload
4848
): Promise<void> {
49-
const requestId = generateRequestId()
49+
const requestId = generateShortId()
5050
try {
5151
const { processPolledWebhookEvent } = await import('@/lib/webhooks/processor')
5252
const result = await processPolledWebhookEvent(

0 commit comments

Comments
 (0)