never-dispose.mjs 720 B

12345678910111213141516171819
  1. /** Test-only Cordis plugin whose disposer announces entry and never settles. */
  2. import { existsSync } from 'node:fs'
  3. /**
  4. * Register a disposer that keeps process shutdown pending until it is forced.
  5. * @param {import('@deepseek-ai/cordis').Context} ctx - loader-mounted test plugin context.
  6. */
  7. export function apply(ctx) {
  8. const keepAlive = setInterval(() => {}, 60_000)
  9. process.stderr.write('dsh-test: never-dispose ready\n')
  10. ctx.effect(() => async () => {
  11. clearInterval(keepAlive)
  12. const armFile = process.env.DSH_TEST_SHUTDOWN_ARM_FILE
  13. if (armFile === undefined || !existsSync(armFile)) return
  14. process.stderr.write('dsh-test: never-dispose started\n')
  15. await new Promise(() => {})
  16. })
  17. }