/** * Test fixture: a hook that outruns its total timeout and then writes a file. * * The marker is the harm, not the mechanism. `Promise.race` in the old * executor rejected at the bound and cancelled nothing, so the hook kept its * capability objects and went on doing work — registering DNS, opening ports — * minutes after celilo reported the deploy failed. A test that only asserts * the rejection cannot see that; it passed throughout (celilo#1003). * * The marker is written AFTER the sleep, so its existence after the bound is * proof the hook was abandoned rather than killed. */ import { writeFileSync } from 'node:fs'; import { defineHook } from '@celilo/capabilities'; export default defineHook({ hook: 'container_created', requires: [], handler: async (ctx) => { ctx.logger.info('runaway hook starting'); await new Promise((r) => setTimeout(r, Number(ctx.config.sleep_ms ?? 2000))); writeFileSync(String(ctx.config.marker_path), 'the hook kept running\n'); }, });