Keep native collection launches responsive

This commit is contained in:
2026-10-05 10:48:38 -04:00
parent dbd2940d29
commit 1405114a14
26 changed files with 998 additions and 123 deletions
+31
View File
@@ -46,6 +46,37 @@ async function seedArtifacts() {
}
describe('launch recipes and previews', () => {
it('keeps detail polling independent of retained plugin bytes after launching', async () => {
const { createScript } = await import('../../src/lib/server/fleet/scripts.js');
const { db, closeDb } = await import('../../src/lib/server/db/index.js');
const plugin = createScript({ name: 'Large utility plugin', kind: 'plugin', scopeType: 'game', scopeValue: 't5',
targetRelPath: 'large.dll', content: Buffer.alloc(8 * 1024 ** 2, 42) });
db().prepare('UPDATE scripts SET current_version_id = ? WHERE id = ?').run(plugin.version.id, plugin.script.id);
const { queueCreateServer, processCreations } = await import('../../src/lib/server/fleet/create.js');
const { getDeployment } = await import('../../src/lib/server/fleet/deployments.js');
const { recipeForDeployment, summarizeRecipe } = await import('../../src/lib/server/fleet/launch-recipes.js');
const queued = queueCreateServer(input);
if (!queued.ok) throw new Error(queued.message);
const queuedSummary = getDeployment(queued.deploymentId)!.recipe!;
await processCreations();
const full = recipeForDeployment(queued.deploymentId)!.recipe;
const expected = summarizeRecipe(full);
expect(expected.fingerprint).not.toBe(queuedSummary.fingerprint);
expect(full.files.find(file => file.path === 'large.dll')?.content).toBe(plugin.version.content.toString('base64'));
closeDb();
const parse = JSON.parse;
const parsing = vi.spyOn(JSON, 'parse').mockImplementation((value, reviver) => {
if (value.length > 1024 * 1024) throw new Error('Detail polling parsed plugin bytes.');
return parse(value, reviver);
});
try {
for (let read = 0; read < 3; read++) expect(getDeployment(queued.deploymentId)?.recipe).toEqual(expected);
const row = db().prepare('SELECT length(recipe_summary) AS bytes FROM server_launch_recipes WHERE deployment_id = ?')
.get(queued.deploymentId) as { bytes: number };
expect(row.bytes).toBeLessThan(10_000);
} finally { parsing.mockRestore(); }
});
it('previews without reserving capacity, saving keys, exposing bytes, or calling Komodo', async () => {
await seedArtifacts();
const { previewCreation } = await import('../../src/lib/server/fleet/create.js');