From 10d16361fae2869367a9f757bfc0ab4c3e04ca2c Mon Sep 17 00:00:00 2001 From: Anso Date: Sun, 29 Mar 2026 23:52:40 -0400 Subject: [PATCH] fix(stacks): avoid resource busy error in Docker fallback deletion (#271) The previous command `rm -rf /cleanup` tried to remove the bind mount point itself, which the kernel rejects with EBUSY. Changed to `find /cleanup -mindepth 1 -maxdepth 1 -exec rm -rf {} +` which removes all contents without touching the mount point. The existing fsPromises.rmdir() call then cleans up the empty host directory. --- backend/src/__tests__/filesystem.test.ts | 2 +- backend/src/services/FileSystemService.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/__tests__/filesystem.test.ts b/backend/src/__tests__/filesystem.test.ts index a67a86e6..ee22cbfc 100644 --- a/backend/src/__tests__/filesystem.test.ts +++ b/backend/src/__tests__/filesystem.test.ts @@ -93,7 +93,7 @@ describe('FileSystemService.deleteStack', () => { await expect(promise).resolves.toBeUndefined(); expect(mockSpawn).toHaveBeenCalledWith( 'docker', - expect.arrayContaining(['run', '--rm', '-v', expect.stringContaining(':/cleanup'), 'alpine', 'rm', '-rf', '/cleanup']), + expect.arrayContaining(['run', '--rm', '-v', expect.stringContaining(':/cleanup'), 'alpine', 'sh', '-c', 'find /cleanup -mindepth 1 -maxdepth 1 -exec rm -rf {} +']), expect.objectContaining({ env: expect.any(Object) }), ); }); diff --git a/backend/src/services/FileSystemService.ts b/backend/src/services/FileSystemService.ts index 8b07a11f..c842b017 100644 --- a/backend/src/services/FileSystemService.ts +++ b/backend/src/services/FileSystemService.ts @@ -205,7 +205,7 @@ export class FileSystemService { 'run', '--rm', '-v', `${dirPath}:/cleanup`, 'alpine', - 'rm', '-rf', '/cleanup' + 'sh', '-c', 'find /cleanup -mindepth 1 -maxdepth 1 -exec rm -rf {} +' ], { env: { ...process.env,