@ultimat3/realtime 31.34.0 → 31.36.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/realtime",
3
- "version": "31.34.0",
3
+ "version": "31.36.0",
4
4
  "description": "Three-tier realtime: channels, live queries, local-first sync — one protocol, one mutator shape",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -52,10 +52,10 @@
52
52
  "test": "bun test"
53
53
  },
54
54
  "dependencies": {
55
- "@ultimat3/core": "31.34.0",
56
- "@ultimat3/entity": "31.34.0",
57
- "@ultimat3/policy": "31.34.0",
58
- "@ultimat3/query": "31.34.0",
55
+ "@ultimat3/core": "31.36.0",
56
+ "@ultimat3/entity": "31.36.0",
57
+ "@ultimat3/policy": "31.36.0",
58
+ "@ultimat3/query": "31.36.0",
59
59
  "nats": "2.29.3"
60
60
  }
61
61
  }
@@ -4,7 +4,7 @@
4
4
  // this is that something, keyed on env rather than a config field so one image deploys everywhere.
5
5
 
6
6
  import type { Clock } from '@ultimat3/core';
7
- import { ConfigInvalidError } from '@ultimat3/core';
7
+ import { ConfigInvalidError, renderFixShellArg } from '@ultimat3/core';
8
8
  import type { AdvisoryLock } from './advisory-lock';
9
9
  import { memoryAdvisoryLock } from './advisory-lock';
10
10
  import type { ChangeFeed } from './changefeed';
@@ -84,7 +84,9 @@ function assertSameDatabase(replicationUrl: string, databaseUrl: string): void {
84
84
  `REPLICATION_URL names ${replication.host}:${replication.port}/${replication.database} but ` +
85
85
  `DATABASE_URL names ${application.host}:${application.port}/${application.database} — the ` +
86
86
  'feed would decode a WAL the app never writes to',
87
- fix: 'point REPLICATION_URL at the same host, port and database as DATABASE_URL, changing only the role',
87
+ // DATABASE_URL's own host, port and database: the one place the replication URL may differ is
88
+ // the role, so the paste carries every part but the credentials.
89
+ fix: `export REPLICATION_URL=postgres://<replication-role>:<password>@${renderFixShellArg(application.host, '<host>')}:${renderFixShellArg(String(application.port), '<port>')}/${renderFixShellArg(application.database, '<db>')} # DATABASE_URL's host, port and database, only the role changed`,
88
90
  meta: { REPLICATION_URL: replication.database, DATABASE_URL: application.database },
89
91
  });
90
92
  }
package/src/changefeed.ts CHANGED
@@ -281,7 +281,7 @@ export class PostgresChangeFeed implements ChangeFeed {
281
281
  throw new ReplicationFailedError({
282
282
  stage: 'preflight',
283
283
  detail: 'the feed was given an empty entity list, so no change could ever match',
284
- fix: 'pass the entities the publication covers: postgresChangeFeed({ entities: [...] })',
284
+ fix: 'postgresChangeFeed({ entities: [...] }) # the entities the publication covers',
285
285
  });
286
286
  }
287
287
  this.#stream = new PgReplicationStream(options);
package/src/errors.ts CHANGED
@@ -204,7 +204,7 @@ export class SubscriptionLimitError extends RealtimeError {
204
204
  fix:
205
205
  args.scope === 'actor'
206
206
  ? `defineConfig({ realtime: { maxSubscriptionsPerActor: ${args.limit * 2} } }) # in app.config.ts — realtime.maxSubscriptionsPerActor; or maxPerActor on new LiveQueryRegistry({…}) where a host builds its own; or unsubscribe unused live queries`
207
- : `raise ${knob} where this sync node is constructed, or unsubscribe unused live queries`,
207
+ : `{ ${knob}: ${args.limit * 2} } # where this sync node is constructed — or unsubscribe unused live queries`,
208
208
  });
209
209
  }
210
210
  }
@@ -222,7 +222,7 @@ export class FrameRateLimitError extends RealtimeError {
222
222
  super({
223
223
  code: 'X_FRAME_RATE_LIMIT',
224
224
  cause: `socket ${args.socketId} exceeded ${args.perSecond} frames per second`,
225
- fix: 'batch subscribes into one frame per subscription and retry after the delay, or raise maxFramesPerSecond where syncNode() is called',
225
+ fix: `syncNode({ maxFramesPerSecond: ${args.perSecond * 2} }) # or batch subscribes into one frame per subscription and retry after the delay`,
226
226
  });
227
227
  }
228
228
  }
@@ -237,7 +237,7 @@ export class SubscriptionIdTakenError extends RealtimeError {
237
237
  super({
238
238
  code: 'X_SUBSCRIPTION_ID_TAKEN',
239
239
  cause: `socket ${args.socketId} already holds a live subscription with sid "${args.sid}"`,
240
- fix: 'send a fresh sid with each subscribe frame — crypto.randomUUID() is what the bundled client uses',
240
+ fix: 'crypto.randomUUID() # a fresh sid with each subscribe frame — what the bundled client uses',
241
241
  });
242
242
  }
243
243
  }
@@ -268,7 +268,7 @@ export class RealtimeTopologyError extends RealtimeError {
268
268
  'role sync runs on an external database over the in-process transport with no replicator in this process, so no committed change can reach it',
269
269
  // Since 31.0.0 the env is the bus (`selectTransport`): NATS_URL set is NATS. A bus of the
270
270
  // app's own is `transport` in its runtime.ts — the line to paste, never a setter to call.
271
- fix: 'set NATS_URL for every realtime role (web, sync, replicator) — or, for a bus of your own, add transport: myTransport to export const runtime = { … } in apps/<app>/runtime.ts — or run the replicator in this process: x dev --role sync,replicator',
271
+ fix: 'export NATS_URL=nats://<host>:4222 # for every realtime role (web, sync, replicator) — or, for a bus of your own, add transport: myTransport to export const runtime = { … } in apps/<app>/runtime.ts — or run the replicator in this process: x dev --role sync,replicator',
272
272
  });
273
273
  }
274
274
  }
@@ -286,7 +286,7 @@ export class TransportProtocolError extends RealtimeError {
286
286
  cause: `transport "${args.transport}" ${args.stage}: ${args.detail}`,
287
287
  fix:
288
288
  args.fix ??
289
- 'x doctor transport — the bus must be nats-server >= 2.11 with JetStream enabled (`nats-server -js`)',
289
+ 'docker run -d -p 4222:4222 nats:2.11-alpine -js # the bus must be nats-server >= 2.11 with JetStream — or point NATS_URL at one',
290
290
  });
291
291
  }
292
292
  }
@@ -308,7 +308,10 @@ export class LiveRowUnidentifiedError extends RealtimeError {
308
308
  ? {
309
309
  code: 'X_LIVE_ROW_UNIDENTIFIED',
310
310
  cause: `live query "${args.query}" returned a row with no id (columns: ${columns})`,
311
- fix: `select the primary key in ${args.query}'s sql(), or drop live: true from it`,
311
+ // The command when the name travels, the list when it does not — then the sql() edit.
312
+ fix: isFixShellSafe(args.query)
313
+ ? `x queries show ${renderFixShellArg(args.query, 'name')} --json # select the primary key in its sql(), or drop live: true from it`
314
+ : 'x queries list --json # select the primary key in its sql(), or drop live: true from it',
312
315
  }
313
316
  : {
314
317
  code: 'X_LIVE_ROW_UNIDENTIFIED',
@@ -359,7 +362,7 @@ export class SocketUnauthenticatedError extends RealtimeError {
359
362
  super({
360
363
  code: 'X_SOCKET_UNAUTHENTICATED',
361
364
  cause: `the websocket upgrade was refused: ${args.reason}`,
362
- fix: 'send the credential syncNode({ authenticate }) reads on the upgrade request, or return an anonymous Actor from it to admit this socket',
365
+ fix: 'syncNode({ authenticate }) # send the credential it reads on the upgrade request, or return an anonymous Actor from it to admit this socket',
363
366
  });
364
367
  }
365
368
  }
@@ -159,7 +159,7 @@ export function parseNatsUrl(url: string): NatsTarget {
159
159
  throw new TransportUnavailableError({
160
160
  transport: 'nats',
161
161
  reason: `the connection URL for ${parsed.hostname} carries a password with no user`,
162
- fix: 'set the URL to nats://<user>:<pass>@host:4222, or the bare-token form nats://<token>@host:4222',
162
+ fix: 'export NATS_URL=nats://<user>:<pass>@host:4222 # or the bare-token form nats://<token>@host:4222',
163
163
  });
164
164
  }
165
165
  const user = hasUser ? decodeCredential(parsed.username, 'user', parsed.hostname) : undefined;
@@ -2,6 +2,7 @@
2
2
  // direct reads that answer "what is under this prefix" in one round trip. Every subject here is
3
3
  // built from a validated bucket name, because a stream name goes straight into a request subject.
4
4
 
5
+ import { renderFixShellArg } from '@ultimat3/core';
5
6
  import { TransportProtocolError, TransportUnavailableError } from './errors';
6
7
  import type { NatsClient, NatsHeaders, NatsMessage } from './nats-client';
7
8
 
@@ -39,7 +40,7 @@ export function assertBucket(bucket: string): void {
39
40
  transport: 'nats',
40
41
  stage: 'bucket',
41
42
  detail: `"${bucket}" is not a bucket name: letters, digits, "-" and "_" only`,
42
- fix: 'set NATS_KV_BUCKET to a name matching [a-zA-Z0-9_-]+, then restart',
43
+ fix: `export NATS_KV_BUCKET=${renderFixShellArg(bucket.replace(/[^a-zA-Z0-9_-]/g, '_'), 'x_presence')} # a name matching [a-zA-Z0-9_-]+, then restart`,
43
44
  });
44
45
  }
45
46
  }
@@ -52,7 +53,7 @@ export function assertServerVersion(version: string): void {
52
53
  transport: 'nats',
53
54
  stage: 'jetstream',
54
55
  detail: `nats-server ${version || '<unknown>'} is older than ${MIN_SERVER.major}.${MIN_SERVER.minor}, which is where batch direct get and per-message TTL landed`,
55
- fix: `run nats:${MIN_SERVER.major}.${MIN_SERVER.minor}-alpine or newer with JetStream enabled (\`nats-server -js\`)`,
56
+ fix: `docker run -d -p 4222:4222 ${renderFixShellArg(`nats:${MIN_SERVER.major}.${MIN_SERVER.minor}-alpine`, 'nats:<version>-alpine')} -js # or newer, with JetStream enabled (nats-server -js)`,
56
57
  });
57
58
  }
58
59
 
@@ -31,7 +31,7 @@ export class RebaseConflictError extends RealtimeError {
31
31
  super({
32
32
  code: 'X_REBASE_CONFLICT',
33
33
  cause: `mutation ${args.key} on ${args.entity} could not be rebased: ${args.reason}`,
34
- fix: "set conflict: 'server-wins' on the mutator, or return a row from custom(merge)",
34
+ fix: "conflict: 'server-wins' # on the mutator — or return a row from custom(merge)",
35
35
  });
36
36
  }
37
37
  }
@@ -140,7 +140,7 @@ export class ServerRenderLiveError extends RealtimeError {
140
140
  super({
141
141
  code: 'X_LIVE_SERVER_RENDER',
142
142
  cause: `${args.operation} ran during a server render, where this app has no live socket`,
143
- fix: 'move the call into an island: x g island <route-dir> --at <route-dir>, import from its mount(), declare island({ src })',
143
+ fix: 'x g island <route-dir> --at <route-dir> # move the call into it: import from its mount(), declare island({ src })',
144
144
  });
145
145
  }
146
146
  }
@@ -151,7 +151,7 @@ export class CursorStaleError extends RealtimeError {
151
151
  super({
152
152
  code: 'X_CURSOR_STALE',
153
153
  cause: `cursor for query ${args.qid} at lsn ${args.lsn} cannot be resumed: ${args.reason}`,
154
- fix: 'pass `snapshot` to resumeFrom() so the fallback path can re-snapshot instead of failing',
154
+ fix: 'resumeFrom(cursor, { source, snapshot }) # so the fallback path can re-snapshot instead of failing',
155
155
  });
156
156
  }
157
157
  }
@@ -52,9 +52,7 @@ export class PostgresAdvisoryLock implements AdvisoryLock {
52
52
  throw new ReplicationFailedError({
53
53
  stage: 'preflight',
54
54
  detail: `advisory lock key "${options.key}" is not [A-Za-z0-9:_.-]+`,
55
- fix:
56
- 'rename the lock key to match [A-Za-z0-9:_.-]+ — it is interpolated into ' +
57
- 'pg_try_advisory_lock(hashtext(...))',
55
+ fix: "postgresAdvisoryLock({ url, key: 'x:replicator:<slot>' }) # a key matching [A-Za-z0-9:_.-]+ — it is interpolated into pg_try_advisory_lock(hashtext(...))",
58
56
  });
59
57
  }
60
58
  this.key = options.key;
package/src/pg-auth.ts CHANGED
@@ -51,7 +51,7 @@ class ScramSha256Session implements ScramSession {
51
51
  throw new ReplicationProtocolError({
52
52
  stage: 'auth',
53
53
  detail: 'clientFinal() was already called on this SCRAM session; a session is single-use',
54
- fix: 'call scramSession() again to start a fresh exchange for the next connection attempt',
54
+ fix: 'scramSession({ password, nonce }) # a fresh exchange for the next connection attempt',
55
55
  });
56
56
  }
57
57
  this.#finalized = true;
@@ -91,7 +91,7 @@ class ScramSha256Session implements ScramSession {
91
91
  throw new ReplicationProtocolError({
92
92
  stage: 'auth',
93
93
  detail: 'verify() was called before clientFinal() produced a server signature to check',
94
- fix: 'call clientFinal() with the server-first-message before verify()',
94
+ fix: 'await session.clientFinal(serverFirst) # with the server-first-message, before verify()',
95
95
  });
96
96
  }
97
97
 
@@ -178,7 +178,7 @@ export function chooseMechanism(offered: readonly string[]): string {
178
178
  offered.length === 0
179
179
  ? 'the server offered no SASL mechanisms'
180
180
  : `the server only offered ${offered.join(', ')} — channel binding ("-PLUS") is not supported here`,
181
- fix: 'set password_encryption = scram-sha-256 on the server and recreate the role password',
181
+ fix: "ALTER ROLE <role> PASSWORD '<password>' -- after SET password_encryption = 'scram-sha-256' in the same session, so the server stores a SCRAM verifier",
182
182
  });
183
183
  }
184
184
 
@@ -64,7 +64,7 @@ const needPassword = (method: string): ReplicationFailedError =>
64
64
  new ReplicationFailedError({
65
65
  stage: 'auth',
66
66
  detail: `the server asked for ${method} but the replication URL carries no password`,
67
- fix: 'put the credentials in the URL: postgres://user:password@host:5432/db',
67
+ fix: 'export REPLICATION_URL=postgres://<user>:<password>@<host>:5432/<db> # the credentials in the URL',
68
68
  });
69
69
 
70
70
  /**
@@ -386,7 +386,7 @@ export class PgConnection {
386
386
  throw new ReplicationProtocolError({
387
387
  stage: 'auth',
388
388
  detail: `the server asked for authentication method ${method}, which this client does not speak`,
389
- fix: 'set password_encryption = scram-sha-256 and give the replication role a password',
389
+ fix: "ALTER ROLE <role> PASSWORD '<password>' -- after SET password_encryption = 'scram-sha-256' in the same session: the replication role needs a SCRAM password",
390
390
  });
391
391
  }
392
392
  }
@@ -47,7 +47,7 @@ export function entityRow(
47
47
  throw new ReplicationProtocolError({
48
48
  stage: 'value',
49
49
  detail: `table "${relation.name}" has no registered entity, so its rows cannot be decoded`,
50
- fix: 'load the app before starting the replicator — runRole({ root, env }) does — or drop the table from the entity list',
50
+ fix: 'runRole({ root, env }) # loads the app before starting the replicator — or drop the table from the entity list',
51
51
  });
52
52
  }
53
53
  const source = image === 'before' ? replicatedOnly(relation, physical) : physical;
@@ -2,11 +2,22 @@
2
2
  // Its own module because the preflight and the publication both assert through it, and either
3
3
  // importing the other for it would close a cycle.
4
4
 
5
+ import { renderFixShellArg } from '@ultimat3/core';
5
6
  import { ReplicationFailedError } from './errors';
6
7
 
7
8
  /** Identifiers reach a simple query unparameterised, so the charset is the injection boundary. */
8
9
  const IDENTIFIER = /^[a-z_][a-z0-9_]*$/;
9
10
 
11
+ /**
12
+ * `My-Slot` → `my_slot`: the nearest name the charset accepts. A name that would not start with a
13
+ * letter is prefixed `x_`, not `_`: core's shell-safe set refuses a leading underscore.
14
+ */
15
+ const foldIdentifier = (value: string): string =>
16
+ value
17
+ .toLowerCase()
18
+ .replace(/[^a-z0-9_]/g, '_')
19
+ .replace(/^(?=[^a-z])|^$/, 'x_');
20
+
10
21
  /**
11
22
  * The one gate between a caller-supplied name and a simple query. `PgReplicationStream` checks its
12
23
  * slot, publication and entity names in its CONSTRUCTOR — a mistyped `REPLICATION_SLOT` is a
@@ -18,6 +29,13 @@ export const assertIdentifier = (kind: string, value: string): string => {
18
29
  throw new ReplicationFailedError({
19
30
  stage: 'preflight',
20
31
  detail: `${kind} "${value}" is not a lower-case postgres identifier`,
21
- fix: `rename the ${kind} to match [a-z_][a-z0-9_]* — it is interpolated into a replication command`,
32
+ // A slot and a publication are env-named (`REPLICATION_SLOT` / `REPLICATION_PUBLICATION`), so
33
+ // their fix is the variable with the name folded into the charset; an entity is a table name.
34
+ fix:
35
+ kind === 'slot'
36
+ ? `export REPLICATION_SLOT=${renderFixShellArg(foldIdentifier(value), 'x_replicator')} # a lower-case postgres identifier: it is interpolated into a replication command`
37
+ : kind === 'publication'
38
+ ? `export REPLICATION_PUBLICATION=${renderFixShellArg(foldIdentifier(value), 'x_changes')} # a lower-case postgres identifier: it is interpolated into a replication command`
39
+ : `rename the ${kind} to match [a-z_][a-z0-9_]* — it is interpolated into a replication command`,
22
40
  });
23
41
  };
@@ -41,7 +41,7 @@ export async function preflight(
41
41
  detail: `wal_level is "${walLevel?.[0] ?? 'unknown'}", so the server writes no logical WAL`,
42
42
  // Not `ALTER SYSTEM`: managed and operator-run Postgres refuse it, and the setting lives in
43
43
  // the provider's configuration. The setting, where it goes, and that it needs a restart.
44
- fix: "set wal_level=logical in the server configuration — postgresql.conf, your managed provider's database flags, or `postgres -c wal_level=logical` on a container — then restart postgres",
44
+ fix: "docker run -d -e POSTGRES_PASSWORD=<password> postgres:17 -c wal_level=logical # a container — elsewhere set wal_level=logical in postgresql.conf or your managed provider's database flags, then restart postgres",
45
45
  });
46
46
  }
47
47
  await ensurePublication(connection, publication, entities);
@@ -313,7 +313,7 @@ export class PgReplicationStream {
313
313
  throw new ReplicationProtocolError({
314
314
  stage: 'stream',
315
315
  detail: `the walsender sent CopyData "${tag}", which is neither XLogData nor a keepalive`,
316
- fix: 'upgrade this package — the server speaks a replication message it does not know',
316
+ fix: 'bun update @ultimat3/realtime # the server speaks a replication message this version does not know',
317
317
  });
318
318
  }
319
319
  }
@@ -378,7 +378,7 @@ export class PgReplicationStream {
378
378
  throw new ReplicationProtocolError({
379
379
  stage: 'stream',
380
380
  detail: `a ${op} arrived outside a transaction`,
381
- fix: 'upgrade this package — the pgoutput stream is framed differently than expected',
381
+ fix: 'bun update @ultimat3/realtime # the pgoutput stream is framed differently than this version expects',
382
382
  });
383
383
  }
384
384
  // Counted for every row, selected or not, so the lsn depends on the WAL alone: narrowing the
package/src/pg-socket.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // and the SSLRequest handshake that has to happen before the first protocol byte. Bun pushes bytes
3
3
  // at handlers while the connection pulls messages, so a queue sits between them.
4
4
 
5
- import { renderThrowable } from '@ultimat3/core';
5
+ import { renderFixShellArg, renderThrowable } from '@ultimat3/core';
6
6
  import { ReplicationFailedError, ReplicationProtocolError, ReplicationTlsError } from './errors';
7
7
  import { judgeHandshake, parseSsl, rootCertificate, type SslMode } from './pg-tls';
8
8
  import { type PgStream, sslRequest } from './pg-wire';
@@ -81,14 +81,14 @@ export function parsePgUrl(url: string): PgTarget {
81
81
  throw new ReplicationFailedError({
82
82
  stage: 'connect',
83
83
  detail: 'DATABASE_URL is not a connection URL',
84
- fix: 'set DATABASE_URL to postgres://user:password@host:5432/database',
84
+ fix: 'export DATABASE_URL=postgres://<user>:<password>@<host>:5432/<database>',
85
85
  });
86
86
  }
87
87
  if (parsed.protocol !== 'postgres:' && parsed.protocol !== 'postgresql:') {
88
88
  throw new ReplicationFailedError({
89
89
  stage: 'connect',
90
90
  detail: `the connection URL uses "${parsed.protocol}" rather than postgres:`,
91
- fix: 'set DATABASE_URL to postgres://user:password@host:5432/database',
91
+ fix: 'export DATABASE_URL=postgres://<user>:<password>@<host>:5432/<database>',
92
92
  });
93
93
  }
94
94
  const { ssl, rootCert } = parseSsl(parsed.searchParams);
@@ -278,7 +278,7 @@ export async function pgStreamOver(runtime: BunConnect, target: PgTarget): Promi
278
278
  const lost = (detail: string): ReplicationTlsError =>
279
279
  new ReplicationTlsError({
280
280
  detail,
281
- fix: `confirm ${target.host}:${target.port} is postgres with ssl=on, or use ?sslmode=disable if it does not speak TLS`,
281
+ fix: `openssl s_client -starttls postgres -connect ${renderFixShellArg(`${target.host}:${target.port}`, '"$PGHOST:$PGPORT"')} </dev/null # a handshake means postgres with ssl=on — or use ?sslmode=disable if it does not speak TLS`,
282
282
  });
283
283
  const tlsHandlers: SocketHandlers = {
284
284
  data: (_socket, data) => queue.push(data.slice()),
@@ -346,7 +346,7 @@ export async function pgStreamOver(runtime: BunConnect, target: PgTarget): Promi
346
346
  throw new ReplicationFailedError({
347
347
  stage: 'ssl',
348
348
  detail: 'the server closed the connection instead of answering the TLS request',
349
- fix: `use ?sslmode=disable if ${target.host} does not speak TLS`,
349
+ fix: `openssl s_client -starttls postgres -connect ${renderFixShellArg(`${target.host}:${target.port}`, '"$PGHOST:$PGPORT"')} </dev/null # no handshake: use ?sslmode=disable if it does not speak TLS`,
350
350
  });
351
351
  }
352
352
  if (verdict === 0x53) {
@@ -356,7 +356,7 @@ export async function pgStreamOver(runtime: BunConnect, target: PgTarget): Promi
356
356
  throw new ReplicationProtocolError({
357
357
  stage: 'ssl',
358
358
  detail: `the server sent ${answer.length - 1} bytes after accepting TLS`,
359
- fix: 'point the replication URL at postgres itself — a proxy answers like this',
359
+ fix: 'export REPLICATION_URL=postgres://<user>:<password>@<postgres-host>:5432/<db> # postgres itself — a proxy answers like this',
360
360
  });
361
361
  }
362
362
  socket = await upgrade();
@@ -366,7 +366,7 @@ export async function pgStreamOver(runtime: BunConnect, target: PgTarget): Promi
366
366
  throw new ReplicationFailedError({
367
367
  stage: 'ssl',
368
368
  detail: `the server refused TLS but sslmode=${target.ssl} was asked for`,
369
- fix: `enable ssl on ${target.host}, or use ?sslmode=prefer to accept a cleartext session`,
369
+ fix: "export REPLICATION_URL='postgres://<user>:<password>@<host>:5432/<db>?sslmode=prefer' # accepts a cleartext session — or enable ssl on the server",
370
370
  });
371
371
  }
372
372
  }
package/src/pg-tls.ts CHANGED
@@ -43,14 +43,14 @@ export function parseSsl(params: URLSearchParams): SslSettings {
43
43
  throw new ReplicationFailedError({
44
44
  stage: 'connect',
45
45
  detail: `sslmode=${mode} is not one of ${SSL_MODES.join(', ')}`,
46
- fix: 'use ?sslmode=verify-full for a managed database, ?sslmode=disable for a local one',
46
+ fix: "export REPLICATION_URL='postgres://<user>:<password>@<host>:5432/<db>?sslmode=verify-full' # a managed database — sslmode=disable for a local one",
47
47
  });
48
48
  }
49
49
  if (rootCert === 'system' && mode !== 'verify-full') {
50
50
  throw new ReplicationFailedError({
51
51
  stage: 'connect',
52
52
  detail: `sslrootcert=system trusts every public CA, so sslmode=${mode} would prove nothing`,
53
- fix: 'use ?sslrootcert=system&sslmode=verify-full, or name your CA: ?sslrootcert=/path/ca.crt',
53
+ fix: "export REPLICATION_URL='postgres://<user>:<password>@<host>:5432/<db>?sslrootcert=system&sslmode=verify-full' # or name your CA: ?sslrootcert=/path/ca.crt",
54
54
  });
55
55
  }
56
56
  if (mode === 'require' && rootCert !== undefined && rootCert !== 'system') {
@@ -110,7 +110,7 @@ export function judgeHandshake(
110
110
  }
111
111
  return new ReplicationTlsError({
112
112
  detail: `the server certificate did not verify (${code}) and sslmode=${target.ssl} checks it`,
113
- fix: 'pass the server CA with ?sslrootcert=/path/to/ca.crt, or use ?sslmode=require to encrypt without verifying',
113
+ fix: "export REPLICATION_URL='postgres://<user>:<password>@<host>:5432/<db>?sslrootcert=/path/to/ca.crt' # the server CA — or ?sslmode=require to encrypt without verifying",
114
114
  });
115
115
  }
116
116
 
@@ -126,7 +126,7 @@ export async function rootCertificate(rootCert: string | undefined): Promise<str
126
126
  if (!(await file.exists())) {
127
127
  throw new ReplicationTlsError({
128
128
  detail: 'sslrootcert names a file that does not exist',
129
- fix: 'mount the server CA and point ?sslrootcert= at it, or use ?sslrootcert=system for a public CA',
129
+ fix: "export REPLICATION_URL='postgres://<user>:<password>@<host>:5432/<db>?sslrootcert=system' # a public CA — or mount the server CA and point ?sslrootcert= at it",
130
130
  });
131
131
  }
132
132
  // `exists()` is not readability: a secret mounted 0600 for another user exists and still refuses
@@ -136,7 +136,7 @@ export async function rootCertificate(rootCert: string | undefined): Promise<str
136
136
  } catch (error) {
137
137
  throw new ReplicationTlsError({
138
138
  detail: `sslrootcert names a file this process cannot read: ${renderThrowable(error)}`,
139
- fix: 'id -u # the replicator runs as this user: mount the CA readable by it, or use ?sslrootcert=system for a public CA',
139
+ fix: 'ls -ln <ca-path> # owner and mode: the replicator runs as $(id -u), so mount the CA readable by it, or use ?sslrootcert=system for a public CA',
140
140
  });
141
141
  }
142
142
  }
package/src/pg-wire.ts CHANGED
@@ -117,7 +117,7 @@ export class MessageReader {
117
117
  throw new ReplicationProtocolError({
118
118
  stage: 'read',
119
119
  detail: `a message declared a length of ${length} bytes`,
120
- fix: 'point the replication URL at postgres itself — a proxy or a TLS port frames like this',
120
+ fix: 'export REPLICATION_URL=postgres://<user>:<password>@<postgres-host>:5432/<db> # postgres itself — a proxy or a TLS port frames like this',
121
121
  });
122
122
  }
123
123
  const total = length + 1;
@@ -96,9 +96,7 @@ export class ReplicaIdentityError extends RealtimeError {
96
96
  cause:
97
97
  `${args.tables.join(', ')} have no replica identity (no primary key, or REPLICA IDENTITY ` +
98
98
  'NOTHING), so once published an UPDATE or DELETE on them fails and a change cannot be keyed',
99
- fix:
100
- `${args.tables.map((table) => `ALTER TABLE ${table} REPLICA IDENTITY FULL;`).join(' ')}` +
101
- ' -- or give each a primary key; rows already in the WAL keep the identity they were written with',
99
+ fix: `ALTER TABLE ${args.tables.join(' REPLICA IDENTITY FULL; ALTER TABLE ')} REPLICA IDENTITY FULL; -- or give each a primary key; rows already in the WAL keep the identity they were written with`,
102
100
  });
103
101
  }
104
102
  }
package/src/sync-node.ts CHANGED
@@ -282,7 +282,7 @@ export function syncNode(options: SyncNodeOptions): SyncNode {
282
282
  // is that every policy on this node is about to be asked about `null`.
283
283
  logger.warn('sync node has no authenticator: every socket is anonymous', {
284
284
  buildId: options.buildId,
285
- fix: 'pass authenticate to syncNode({ authenticate })',
285
+ fix: "syncNode({ authenticate }) # nothing else can name a socket's actor",
286
286
  });
287
287
  }
288
288
  ready = true;