MCPcopy Index your code
hub / github.com/simstudioai/sim / dropOperationForMissingTarget

Function dropOperationForMissingTarget

apps/sim/stores/operation-queue/store.ts:82–116  ·  view source on GitHub ↗

* Drops a failed operation whose target entity no longer exists locally (e.g. it * was removed by a remote collaborator while the operation was in flight), so a * stale per-entity failure does not trip offline mode. Applies only to block-, * subblock-, subflow-, and variable-scoped operations; st

(operation: QueuedOperation)

Source from the content-addressed store, hash-verified

80 * to offline mode. Returns true when the operation was dropped.
81 */
82function dropOperationForMissingTarget(operation: QueuedOperation): boolean {
83 const { target, payload } = operation.operation
84
85 const isVariableOperation = target === 'variable'
86 if (!isVariableOperation && !BLOCK_SCOPED_TARGETS.includes(target)) {
87 return false
88 }
89
90 const targetId = isVariableOperation
91 ? payload?.variableId || payload?.id
92 : payload?.blockId || payload?.id
93 const targetStillPresent = isVariableOperation
94 ? isVariableStillPresent(targetId)
95 : isBlockStillPresent(targetId)
96
97 if (!targetId || targetStillPresent) {
98 return false
99 }
100
101 logger.debug(
102 isVariableOperation
103 ? 'Dropping failed operation for deleted variable'
104 : 'Dropping failed operation for deleted block',
105 {
106 operationId: operation.id,
107 targetId,
108 }
109 )
110 useOperationQueueStore.setState((s) => ({
111 operations: s.operations.filter((op) => op.id !== operation.id),
112 isProcessing: false,
113 }))
114 useOperationQueueStore.getState().processNextOperation()
115 return true
116}
117
118export const useOperationQueueStore = create<OperationQueueState>((set, get) => ({
119 operations: [],

Callers 1

store.tsFile · 0.85

Calls 3

isVariableStillPresentFunction · 0.85
isBlockStillPresentFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected