mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-19 02:34:37 -05:00
fix(lock): prevent socket crash when locking agent blocks (#3245)
This commit is contained in:
@@ -618,6 +618,15 @@ export function Editor() {
|
||||
<div className='h-[1.25px] flex-1' style={DASHED_DIVIDER_STYLE} />
|
||||
</div>
|
||||
)}
|
||||
{hasAdvancedOnlyFields && !canEditBlock && displayAdvancedOptions && (
|
||||
<div className='flex items-center gap-[10px] px-[2px] pt-[14px] pb-[12px]'>
|
||||
<div className='h-[1.25px] flex-1' style={DASHED_DIVIDER_STYLE} />
|
||||
<span className='whitespace-nowrap font-medium text-[13px] text-[var(--text-secondary)]'>
|
||||
Additional fields
|
||||
</span>
|
||||
<div className='h-[1.25px] flex-1' style={DASHED_DIVIDER_STYLE} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{advancedOnlySubBlocks.map((subBlock, index) => {
|
||||
const stableKey = getSubBlockStableKey(
|
||||
|
||||
@@ -232,6 +232,7 @@ async function flushSubblockUpdate(
|
||||
}
|
||||
|
||||
let updateSuccessful = false
|
||||
let blockLocked = false
|
||||
await db.transaction(async (tx) => {
|
||||
const [block] = await tx
|
||||
.select({
|
||||
@@ -250,6 +251,7 @@ async function flushSubblockUpdate(
|
||||
// Check if block is locked directly
|
||||
if (block.locked) {
|
||||
logger.info(`Skipping subblock update - block ${blockId} is locked`)
|
||||
blockLocked = true
|
||||
return
|
||||
}
|
||||
|
||||
@@ -266,6 +268,7 @@ async function flushSubblockUpdate(
|
||||
|
||||
if (parentBlock?.locked) {
|
||||
logger.info(`Skipping subblock update - parent ${parentId} is locked`)
|
||||
blockLocked = true
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -308,6 +311,13 @@ async function flushSubblockUpdate(
|
||||
serverTimestamp: Date.now(),
|
||||
})
|
||||
})
|
||||
} else if (blockLocked) {
|
||||
pending.opToSocket.forEach((socketId, opId) => {
|
||||
io.to(socketId).emit('operation-confirmed', {
|
||||
operationId: opId,
|
||||
serverTimestamp: Date.now(),
|
||||
})
|
||||
})
|
||||
} else {
|
||||
pending.opToSocket.forEach((socketId, opId) => {
|
||||
io.to(socketId).emit('operation-failed', {
|
||||
|
||||
Reference in New Issue
Block a user