You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevent port conflicts when launching multiple installs concurrently (#94)
* fix: prevent port conflicts when launching multiple installs concurrently
Port reservation and instance detection previously only took effect after
full boot (up to 2 minutes), creating a race window where concurrent
launches could claim the same port.
Main process:
- Add in-memory _pendingPorts map to track ports during boot
- Check pending reservations in port conflict detection
- Pass reserved ports as exclusions to findAvailablePort
- Add TOCTOU re-check before reserving to close async gap
- Broadcast instance-launching/instance-launch-failed events
Renderer:
- Track launchingInstances in sessionStore via new IPC events
- Update useLocalInstanceGuard to warn about booting instances
Tests: 18 new tests across process.test.ts, sessionStore.test.ts,
and useLocalInstanceGuard.test.ts
Amp-Thread-ID: https://ampcode.com/threads/T-019caeaa-8ead-722d-942d-5aee9307865e
Co-authored-by: Amp <amp@ampcode.com>
* fix: retry rename on EPERM/EACCES in safe file writes (Windows)
On Windows, antivirus or file indexer can briefly lock files after a
write, causing EPERM on the atomic rename step. Add retry logic (up to
3 attempts with backoff) to both sync and async writeFileSafe variants.
Clean up leftover .tmp files on permanent failure.
Amp-Thread-ID: https://ampcode.com/threads/T-019caeaa-8ead-722d-942d-5aee9307865e
Co-authored-by: Amp <amp@ampcode.com>
* fix: drop busy-wait retry from sync writeFileSafe, keep async only
The sync busy-wait blocks the event loop for up to 600ms. Instead, rely
on readFileSafe's .bak fallback for recovery. Add a future enhancement
note in DESIGN_PROCESS.md to convert sync callers to async.
Amp-Thread-ID: https://ampcode.com/threads/T-019caeaa-8ead-722d-942d-5aee9307865e
Co-authored-by: Amp <amp@ampcode.com>
---------
Co-authored-by: Amp <amp@ampcode.com>
Copy file name to clipboardExpand all lines: DESIGN_PROCESS.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -194,3 +194,21 @@ When reviewing code for modularity, check:
194
194
5.**Does a renderer view contain hardcoded conditionals for specific action/source IDs?** Replace with a data-driven pattern (add a property to the schema).
195
195
6.**Does a source repeat information already available from its own definition?** Have the framework (ipc.js) inject it.
196
196
7.**Can a new source be added by only creating a file in `sources/` and registering it in `sources/index.js`?** If not, something is coupled.
197
+
198
+
## Future Enhancements
199
+
200
+
### Convert `writeFileSafe` callers to async
201
+
202
+
The synchronous `writeFileSafe` in `lib/safe-file.ts` cannot safely retry on
203
+
Windows `EPERM`/`EACCES` rename errors (retry would require a busy-wait that
204
+
blocks the event loop). The async variant `writeFileSafeAsync` handles this
205
+
with proper `setTimeout`-based retries.
206
+
207
+
Callers that should be migrated to `writeFileSafeAsync`:
208
+
-`src/main/settings.ts` — `set()` function
209
+
-`src/main/lib/release-cache.ts` — `save()` function
0 commit comments