session-store-concurrent-process.ts 947 B

12345678910111213141516171819202122232425262728293031
  1. import { openStartupSqliteSessionStore } from "../../src/storage/index.ts";
  2. process.send?.({ type: "ready" });
  3. process.once("message", (message: { dbPath?: unknown; type?: unknown }) => {
  4. if (message.type !== "start" || typeof message.dbPath !== "string") {
  5. process.exitCode = 1;
  6. process.disconnect?.();
  7. return;
  8. }
  9. try {
  10. const store = openStartupSqliteSessionStore({ dbPath: message.dbPath });
  11. const migrationIds = store.debugMigrationIds();
  12. store.close();
  13. process.send?.({ result: { migrationIds, ok: true }, type: "result" });
  14. } catch (error) {
  15. process.send?.({
  16. result: {
  17. kind:
  18. typeof error === "object" && error !== null && "kind" in error
  19. ? String(error.kind)
  20. : undefined,
  21. message: error instanceof Error ? error.message : String(error),
  22. ok: false,
  23. },
  24. type: "result",
  25. });
  26. } finally {
  27. process.disconnect?.();
  28. }
  29. });