Bug Report: Spontaneous File Deletion / “Resolve Conflicts” triggered by AI Prompt Submission (I/O Timeout on OPFS)
Environment:
-
Browser: Microsoft Edge (Chromium-based)
-
Platform: Google AI Studio (Web IDE / Build workspace)
-
Project Stack: React, Vite, Firebase, TypeScript
Description: There is a critical race condition / I/O thread starvation issue in the AI Studio web IDE. When working on a moderately complex project, submitting a prompt to the AI triggers an internal workspace snapshot. Under high browser resource load, the IDE’s virtual file system (IndexedDB/OPFS) fails to read local files in time. Instead of handling the timeout gracefully, the IDE interprets the unread files as being completely empty (0 bytes) or manually deleted by the user.
This triggers a massive automatic deletion of crucial project files (typically src/lib/*), prompting a “Resolve conflicts” modal and syncing the deletion to the cloud server.
Steps to Reproduce:
-
Open a sufficiently large project in the AI Studio IDE (e.g., a React app with Firebase SDKs, Stripe, and multiple configuration files in
src/lib/). -
Keep the Live Preview (Vite/HMR) running.
-
Open the AI Chat panel and type a prompt.
-
Press
Enterto send the prompt to the AI. -
Immediate Result: The files in
src/lib/disappear from the file tree, and a “Resolve conflicts” modal pops up asking to accept the deletion of these files.
Expected Behavior: The IDE should capture the workspace state for the AI context without corrupting or modifying the user’s local file tree. If a file read fails due to a timeout, it should retry or throw a read error, not assume the file was emptied or deleted.
Actual Behavior & Technical Evidence: Through extensive DevTools debugging during the exact millisecond of the crash, the following sequence was captured:
-
The Snapshot Trigger: Hitting
Enteron the prompt immediately fires theCreateUserSnapshotnetwork request to gather context for the AI. -
Resource Spike: Simultaneously,
tsWorker.js(1.3 MB) is actively running, and Vite is handling HMR. -
OPFS Read Failure: The virtual file system attempts to read the files (e.g.,
firebase.ts,platform.ts,i18n.ts). Due to the I/O bottleneck in Edge/Chromium, the read times out or returns empty buffers. -
False Conflict Generation: The IDE interprets this read failure as the user deleting all text inside the files. The “Resolve conflicts” UI appears, showing
-55 lines changed,-85 lines changed, etc., for each file. -
Cloud Sync of the Bug: A split second later, an
ApplyFileSystemOperationXHR request is fired, committing the deletion to the cloud. The AI system prompt logs internally register: “The USER performed the following action: Delete file /src/lib/firebase.ts”.
Additional Debugging Context Attempted:
-
Network Cache: Initially, we noticed Vite’s HMR was hitting
304 Not Modifiedstates concurrently. Checking “Disable cache” in Edge DevTools forced200 OKfetches, which stabilized the previewer but did not stop the IDE snapshot from deleting the files upon pressing Enter. -
IndexedDB Reset: Running “Clear site data” resets the corrupt workspace and forces a fresh pull from the cloud, but the bug reoccurs as soon as the project scales and the user sends a new prompt under load.
Root Cause Hypothesis: The AI Studio workspace syncing engine lacks a failsafe for read timeouts on the browser’s OPFS/IndexedDB. When CreateUserSnapshot requests the file tree, any file that cannot be read in time due to thread starvation is incorrectly flagged as a user-initiated deletion (or file truncation to 0 bytes), which is then aggressively synced to the server via ApplyFileSystemOperation.