Description
On native Windows, GJC intermittently fails while appending messages to managed session storage.
The failure is not tied to a specific project directory. It has occurred in multiple workspaces while the GJC session data was stored under:
C:\Users\<user>\.gjc\agent\
The error appears to happen during the managed-file replacement operation.
Steps to Reproduce
The failure is intermittent, but the observed sequence is:
- Install and run GJC globally with Bun on native Windows.
- Start GJC in a project directory.
- Continue using the session so that messages are appended to the managed session storage.
- In some cases, the managed-file replacement fails with
managed_replace_failed:io_error.
- GJC records the crash in
C:\Users\<user>\.gjc\agent\gjc-crash.log.
The issue has occurred in more than one project, so it does not appear to be project-specific.
Expected Behavior
A temporary Windows file-sharing conflict should not crash the active GJC session.
The managed-file replacement should retry transient, pre-mutation I/O failures for a short bounded period and then either:
- complete successfully, or
- return a more specific diagnostic describing the affected path and Windows error code.
Error Output
[Unhandled Rejection] ManagedReplaceError: managed_replace_failed:io_error
at replaceManagedFileGeneratedSync (...\managed-session-storage.ts:2806:15)
at appendSync (...\managed-session-storage.ts:1552:21)
at <anonymous> (...\session-manager.ts:15637:26)
at #appendManagedRecordsSync (...\session-manager.ts:15630:8)
at <anonymous> (...\session-manager.ts:15761:11)
at _persist (...\session-manager.ts:15753:9)
at #appendEntryWithinPersistenceFence (...\session-manager.ts:15841:9)
at #withSessionPersistenceFenceSync (...\session-manager.ts:10471:11)
at #appendEntry (...\session-manager.ts:15792:8)
at appendMessage (...\session-manager.ts:16006:8)
{"code":"io_error"}
Platform
Windows (native)
gjc version
0.13.1
Bun version
1.3.14
Area
Session / Compaction
Additional Context
The session directory is on the user's local Windows filesystem, not inside the project directory.
Disk space and directory permissions were checked, and the user has full control of the session directory.
A controlled test was also performed by temporarily opening the destination file without delete sharing for approximately 1.2 seconds. This reproduced the transient replacement conflict.
As a proof of concept, a local patch was tested with bounded retries only when all of the following were true:
- Platform is Windows.
- The returned code is
io_error.
detachedOldPath is undefined.
retainedNewPath is undefined.
retainedNewIdentityPath is undefined.
With 30 retries and a 100 ms delay, the controlled replacement completed successfully after approximately 1.34 seconds, and the resulting file contents were correct.
The retry condition was intentionally limited to a bare, pre-mutation io_error so that failures occurring after a namespace mutation would not be retried blindly.
It may also be useful for the native replacement function to preserve the underlying Windows error code, such as a sharing violation, instead of returning only io_error.
Description
On native Windows, GJC intermittently fails while appending messages to managed session storage.
The failure is not tied to a specific project directory. It has occurred in multiple workspaces while the GJC session data was stored under:
C:\Users\<user>\.gjc\agent\The error appears to happen during the managed-file replacement operation.
Steps to Reproduce
The failure is intermittent, but the observed sequence is:
managed_replace_failed:io_error.C:\Users\<user>\.gjc\agent\gjc-crash.log.The issue has occurred in more than one project, so it does not appear to be project-specific.
Expected Behavior
A temporary Windows file-sharing conflict should not crash the active GJC session.
The managed-file replacement should retry transient, pre-mutation I/O failures for a short bounded period and then either:
Error Output
[Unhandled Rejection] ManagedReplaceError: managed_replace_failed:io_error at replaceManagedFileGeneratedSync (...\managed-session-storage.ts:2806:15) at appendSync (...\managed-session-storage.ts:1552:21) at <anonymous> (...\session-manager.ts:15637:26) at #appendManagedRecordsSync (...\session-manager.ts:15630:8) at <anonymous> (...\session-manager.ts:15761:11) at _persist (...\session-manager.ts:15753:9) at #appendEntryWithinPersistenceFence (...\session-manager.ts:15841:9) at #withSessionPersistenceFenceSync (...\session-manager.ts:10471:11) at #appendEntry (...\session-manager.ts:15792:8) at appendMessage (...\session-manager.ts:16006:8) {"code":"io_error"}Platform
Windows (native)
gjc version
0.13.1
Bun version
1.3.14
Area
Session / Compaction
Additional Context
The session directory is on the user's local Windows filesystem, not inside the project directory.
Disk space and directory permissions were checked, and the user has full control of the session directory.
A controlled test was also performed by temporarily opening the destination file without delete sharing for approximately 1.2 seconds. This reproduced the transient replacement conflict.
As a proof of concept, a local patch was tested with bounded retries only when all of the following were true:
io_error.detachedOldPathis undefined.retainedNewPathis undefined.retainedNewIdentityPathis undefined.With 30 retries and a 100 ms delay, the controlled replacement completed successfully after approximately 1.34 seconds, and the resulting file contents were correct.
The retry condition was intentionally limited to a bare, pre-mutation
io_errorso that failures occurring after a namespace mutation would not be retried blindly.It may also be useful for the native replacement function to preserve the underlying Windows error code, such as a sharing violation, instead of returning only
io_error.