Skip to content

fix: defer active compile directory cleanup - #101

Merged
ttbombadil merged 1 commit into
mainfrom
fix/defer-compile-directory-cleanup
Sep 17, 2026
Merged

ttbombadil merged 1 commit into
mainfrom
fix/defer-compile-directory-cleanup

Conversation

@ttbombadil

Copy link
Copy Markdown
Collaborator

Summary

  • prevents SandboxRunner.stop() from cleaning the active sketch/output directory while local compilation is still in progress
  • preserves cleanup of unrelated stale tracked directories
  • reuses the existing deferred cleanup path after compilation settles
  • adds deterministic regression coverage for stop-during-compile and normal cleanup behavior

Root cause

markTempDirForCleanup() already defers cleanup while isCompiling or localCompiler.isBusy is true.

However, SandboxRunner.stop() subsequently iterated all directories returned by getCreatedSketchDirs() and called attemptCleanupDir() directly.

That bypassed the compile guard and could rename the active directory to .cleanup while compilation still needed it.

Observed production log symptom:

[RaceCondition] Output directory vanished before g++ spawn

Fix

While compilation is active, the direct tracked-directory cleanup loop skips only the active compile directory.

Other stale tracked directories continue to be cleaned.

After the compile settles, the existing deferred cleanup path processes the active directory and clears its tracking.

Regression coverage

  • stop during active compilation:
    • active compile directory remains available
    • stale tracked directory is still cleaned
    • deferred cleanup remains pending
    • active directory is cleaned exactly once after compile completion
  • stop without active compilation:
    • existing cleanup behavior remains unchanged

The race test uses a controlled Promise and no timing sleeps.

Validation

  • focused SandboxRunner + FilesystemHelper tests: 42/42 PASS
  • npm run check: PASS
  • npm test: 2113/2113 PASS
  • npm run test:coverage: PASS
    • Lines: 86.53%
    • Statements: 84.44%
    • Functions: 85.16%
    • Branches: 73.24%
  • npm run test:integration: 13 PASS, 1 SKIP
  • git diff --check: PASS

Scope

  • no CI changes
  • no timeout changes
  • no retry changes
  • no rate-limit changes
  • no changes to UnoSim_Test

@ttbombadil
ttbombadil merged commit 8046013 into main Sep 17, 2026
5 checks passed
@ttbombadil
ttbombadil deleted the fix/defer-compile-directory-cleanup branch September 18, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant