@lightupai/polaris 0.0.103 → 0.0.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Makefile CHANGED
@@ -18,7 +18,7 @@ dev: dev-up css api web daemon bridge
18
18
 
19
19
  # Postgres
20
20
  dev-up:
21
- docker compose up -d
21
+ docker compose up -d --wait
22
22
 
23
23
  dev-down:
24
24
  docker compose down
@@ -9,6 +9,11 @@ services:
9
9
  - "5432:5432"
10
10
  volumes:
11
11
  - polaris-pgdata:/var/lib/postgresql/data
12
+ healthcheck:
13
+ test: ["CMD-SHELL", "pg_isready -U polaris -d polaris"]
14
+ interval: 5s
15
+ timeout: 5s
16
+ retries: 10
12
17
 
13
18
  volumes:
14
19
  polaris-pgdata:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightupai/polaris",
3
- "version": "0.0.103",
3
+ "version": "0.0.104",
4
4
  "description": "Record and stream Claude Code sessions to Slack. Like Gong for AI coding — capture every prompt, response, and tool call. Multiplayer collaboration across AI coding agents.",
5
5
  "keywords": [
6
6
  "claude-code",
package/src/service/db.ts CHANGED
@@ -34,8 +34,39 @@ export interface ProjectMember {
34
34
  // --- Schema ---
35
35
 
36
36
  export async function createDb(connectionString?: string): Promise<Sql> {
37
- const sql = postgres(connectionString ?? process.env.DATABASE_URL ?? "postgres://polaris:polaris@localhost:5432/polaris");
38
- await ensureSchema(sql);
37
+ const connStr = connectionString ?? process.env.DATABASE_URL ?? "postgres://polaris:polaris@localhost:5432/polaris";
38
+ const sql = postgres(connStr);
39
+ // Retry on transient startup errors (ECONNREFUSED, "starting up" 57P03).
40
+ // Fail fast on auth/role/database errors — retrying won't help.
41
+ const TRANSIENT_CODES = new Set(["57P03", "ECONNREFUSED"]);
42
+ const FATAL_CODES = new Set(["28000", "28P01", "3D000"]);
43
+ const MAX_ATTEMPTS = 10;
44
+ const RETRY_DELAY_MS = 1000;
45
+ for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
46
+ try {
47
+ await ensureSchema(sql);
48
+ return sql;
49
+ } catch (err: unknown) {
50
+ const code = (err as { code?: string }).code ?? "";
51
+ if (FATAL_CODES.has(code)) {
52
+ throw new Error(
53
+ `Database connection failed (${code}): ${(err as Error).message}\n` +
54
+ `Hint: the role/password/database may not exist. ` +
55
+ `Try: docker compose down -v && docker compose up -d --wait`
56
+ );
57
+ }
58
+ if (!TRANSIENT_CODES.has(code) && attempt === MAX_ATTEMPTS) {
59
+ throw err;
60
+ }
61
+ if (attempt < MAX_ATTEMPTS) {
62
+ console.error(`[db] connection attempt ${attempt}/${MAX_ATTEMPTS} failed (${code}), retrying in ${RETRY_DELAY_MS}ms...`);
63
+ await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
64
+ } else {
65
+ throw err;
66
+ }
67
+ }
68
+ }
69
+ // unreachable
39
70
  return sql;
40
71
  }
41
72