Spaces:
Build error
Build error
File size: 1,187 Bytes
75fefa7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import { NextResponse } from 'next/server';
declare global {
var activeSandboxProvider: any;
var sandboxData: any;
var existingFiles: Set<string>;
}
export async function POST() {
try {
console.log('[kill-sandbox] Stopping active sandbox...');
let sandboxKilled = false;
// Stop existing sandbox if any
if (global.activeSandboxProvider) {
try {
await global.activeSandboxProvider.terminate();
sandboxKilled = true;
console.log('[kill-sandbox] Sandbox stopped successfully');
} catch (e) {
console.error('[kill-sandbox] Failed to stop sandbox:', e);
}
global.activeSandboxProvider = null;
global.sandboxData = null;
}
// Clear existing files tracking
if (global.existingFiles) {
global.existingFiles.clear();
}
return NextResponse.json({
success: true,
sandboxKilled,
message: 'Sandbox cleaned up successfully'
});
} catch (error) {
console.error('[kill-sandbox] Error:', error);
return NextResponse.json(
{
success: false,
error: (error as Error).message
},
{ status: 500 }
);
}
} |