session-migration-crash-process.ts 646 B

123456789101112131415161718
  1. import { SqliteSessionStore } from "../../src/storage/session-store/sqlite-session-store.js";
  2. process.once("message", async (input: { dbPath: string; stopAt: "committing" | "ready" }) => {
  3. await SqliteSessionStore.openStartup(
  4. { dbPath: input.dbPath },
  5. {
  6. onProgress: async (progress) => {
  7. if (progress.phase !== input.stopAt) return;
  8. process.send?.({ type: "barrier" });
  9. // 持续连接 IPC 让父进程在真实事务边界终止此子进程。
  10. await new Promise<void>(() => {
  11. process.on("message", () => {});
  12. });
  13. },
  14. },
  15. );
  16. });
  17. process.send?.({ type: "listening" });