Skip to content

The agent that grows with you

fix(desktop): size the rcedit retry to the observed lock window and retry any failure

teknium1f501ebcf1ef5
diff --git a/apps/desktop/scripts/set-exe-identity.mjs b/apps/desktop/scripts/set-exe-identity.mjs
index a1e67fab5d6..091857a9b39 100644
--- a/apps/desktop/scripts/set-exe-identity.mjs
+++ b/apps/desktop/scripts/set-exe-identity.mjs
@@ -42,7 +42,13 @@ import { rcedit } from 'rcedit'
import { isMain } from './utils.mjs'
-const RCEDIT_COMMIT_RETRY_DELAYS_MS = [100, 300]
+// A real-time file scanner (AV/EDR) holds a short exclusive handle on a freshly
+// written exe; rcedit's resource commit then fails with "Unable to commit
+// changes" and succeeds seconds later on identical input. Retrying on ANY
+// rcedit failure keeps the shape simple — a permanent failure costs 3.5 s more
+// before after-pack.mjs swallows it. Delays sized to the field report: the
+// lock was still held 5 s after a first attempt in some runs.
+const RCEDIT_COMMIT_RETRY_DELAYS_MS = [500, 1000, 2000]
function wait(delay) {
return new Promise(resolve => setTimeout(resolve, delay))
@@ -85,10 +91,10 @@ async function stampExeIdentity(
break
} catch (err) {
const delay = RCEDIT_COMMIT_RETRY_DELAYS_MS[attempt]
- if (!/unable to commit changes/i.test(err?.message) || delay === undefined) {
+ if (delay === undefined) {
throw err
}
- console.warn(`[set-exe-identity] rcedit commit failed; retrying in ${delay}ms (${err.message})`)
+ console.warn(`[set-exe-identity] rcedit failed; retrying in ${delay}ms (${err.message})`)
await sleep(delay)
}
}
diff --git a/apps/desktop/scripts/set-exe-identity.test.mjs b/apps/desktop/scripts/set-exe-identity.test.mjs
index 0f02e77bf94..68c8c6e6446 100644
--- a/apps/desktop/scripts/set-exe-identity.test.mjs
+++ b/apps/desktop/scripts/set-exe-identity.test.mjs
@@ -30,7 +30,7 @@ test('retries transient rcedit commit failures with bounded backoff', async () =
})
assert.equal(attempts, 3)
- assert.deepEqual(delays, [100, 300])
+ assert.deepEqual(delays, [500, 1000])
} finally {
fs.rmSync(root, { recursive: true, force: true })
}
@@ -51,7 +51,7 @@ test('stops retrying after the bounded rcedit retry budget is exhausted', async
}),
/Unable to commit changes/
)
- assert.equal(attempts, 3)
+ assert.equal(attempts, 4)
} finally {
fs.rmSync(root, { recursive: true, force: true })
}