Fix blocking collection matching with large plugins
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { listCollections, queueCollection } from '$lib/server/fleet/collections.js';
|
||||
import { kick } from '$lib/server/pipeline/worker.js';
|
||||
import { kickProvisioning } from '$lib/server/pipeline/worker.js';
|
||||
|
||||
export function GET() { return json({ collections: listCollections() }); }
|
||||
|
||||
@@ -9,7 +9,11 @@ export async function POST({ request }: { request: Request }) {
|
||||
const body = await request.json();
|
||||
if (!body || typeof body !== 'object' || Array.isArray(body)) throw new Error('Provide a collection preview and its server keys.');
|
||||
const result = queueCollection(body);
|
||||
if (result.collectionId) void kick().catch(err => console.error('[collection] worker kick failed:', err));
|
||||
// The durable queue is committed. Let the response and pending I/O run
|
||||
// before provisioning loads launch files or starts checking removals.
|
||||
if (result.collectionId) setImmediate(() => {
|
||||
void kickProvisioning().catch(err => console.error('[collection] worker kick failed:', err));
|
||||
});
|
||||
return json(result, { status: result.collectionId ? 202 : 200 });
|
||||
} catch (err) { return json({ error: (err as Error).message }, { status: 400 }); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user