@runeditrun/rer 0.2.23 → 0.2.25

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.
Files changed (77) hide show
  1. package/README.md +16 -7
  2. package/cli/browser-runtime.mjs +65 -0
  3. package/cli/demo-host.mjs +1 -1
  4. package/cli/deploy-claim-request.mjs +5 -4
  5. package/cli/deploy-command.mjs +7 -5
  6. package/cli/deploy-inputs.mjs +2 -1
  7. package/cli/deploy-observation.mjs +20 -2
  8. package/cli/deploy-owner.mjs +12 -7
  9. package/cli/deploy.mjs +19 -6
  10. package/cli/export.mjs +1 -1
  11. package/cli/hydration/browser.mjs +3 -9
  12. package/cli/inspect.mjs +3 -1
  13. package/cli/lifecycle.mjs +4 -1
  14. package/cli/site.mjs +2 -2
  15. package/global/CHANGELOG.md +37 -0
  16. package/global/README.md +16 -7
  17. package/global/browser-runtime.mjs +45 -0
  18. package/global/cli/layout.mjs +8 -4
  19. package/global/main.mjs +13 -3
  20. package/install.sh +56 -3
  21. package/modules/container/README.md +6 -0
  22. package/modules/container/adapters/d1.mjs +1 -1
  23. package/modules/container/build.mjs +2 -1
  24. package/modules/container/image-variables.mjs +27 -0
  25. package/modules/container/transfer.mjs +0 -1
  26. package/modules/container/worker-engine.mjs +1 -1
  27. package/modules/delivery-producer/declarations.mjs +6 -1
  28. package/modules/delivery-producer/mail.mjs +66 -0
  29. package/modules/demo/label.mjs +5 -2
  30. package/modules/demo-host/README.md +29 -7
  31. package/modules/demo-host/container.mjs +19 -7
  32. package/modules/demo-host/placement.mjs +19 -5
  33. package/modules/demo-host/plan.mjs +11 -6
  34. package/modules/demo-host/start-script.mjs +2 -1
  35. package/modules/demo-host/startup.mjs +3 -3
  36. package/modules/demo-host/worker.mjs +27 -8
  37. package/modules/deploy-kit/README.md +41 -6
  38. package/modules/deploy-kit/asset-health.mjs +28 -0
  39. package/modules/deploy-kit/d1-import.mjs +22 -4
  40. package/modules/deploy-kit/diagnostics.mjs +46 -1
  41. package/modules/deploy-kit/health.mjs +2 -23
  42. package/modules/deploy-kit/migration-ledger.mjs +6 -2
  43. package/modules/deploy-kit/migration-retry.mjs +91 -0
  44. package/modules/deploy-kit/migrations.mjs +9 -5
  45. package/modules/deploy-kit/owner-cli.mjs +9 -6
  46. package/modules/deploy-kit/owner-remove.mjs +104 -64
  47. package/modules/deploy-kit/pagination.mjs +99 -0
  48. package/modules/deploy-kit/provider-transport.mjs +28 -5
  49. package/modules/deploy-kit/provider.mjs +38 -75
  50. package/modules/deploy-kit/r2-objects.mjs +6 -17
  51. package/modules/deploy-kit/site-readback.mjs +67 -0
  52. package/modules/deploy-kit/site.mjs +17 -31
  53. package/modules/deploy-kit/uploaded-worker.mjs +9 -3
  54. package/modules/deploy-kit/worker.mjs +5 -2
  55. package/modules/erasure/queue.mjs +0 -2
  56. package/modules/job-queue/cli.mjs +1 -1
  57. package/modules/operator-auth/README.md +10 -2
  58. package/modules/operator-auth/config.mjs +1 -0
  59. package/modules/operator-auth/conformance/presentation.mjs +2 -2
  60. package/modules/operator-auth/identity/email-link/confirmation.mjs +2 -1
  61. package/modules/operator-auth/identity/email-link/expiry.mjs +8 -0
  62. package/modules/operator-auth/identity/email-link/index.mjs +2 -1
  63. package/modules/operator-auth/identity/email-link/message.mjs +3 -2
  64. package/modules/operator-auth/identity/oidc/jwt.mjs +1 -1
  65. package/modules/operator-auth/index.d.mts +2 -0
  66. package/modules/portability/README.md +7 -2
  67. package/modules/portability/bridge.mjs +3 -3
  68. package/modules/portability/catalogue.mjs +1 -1
  69. package/modules/portability/cli-options.mjs +1 -1
  70. package/modules/portability/import-staging.mjs +45 -0
  71. package/modules/portability/import.mjs +8 -8
  72. package/modules/portability/legacy-files.mjs +1 -1
  73. package/modules/portability/legacy-safety.mjs +3 -3
  74. package/modules/portability/payloads.mjs +1 -1
  75. package/modules/portability/storage.mjs +5 -2
  76. package/modules/release/source.mjs +1 -1
  77. package/package.json +1 -1
package/README.md CHANGED
@@ -22,13 +22,19 @@ refuses archives with absolute paths, `..` entries, links or devices, then runs
22
22
  the package's own `rer cli install`. A failed or refused download leaves the
23
23
  version you had selected.
24
24
 
25
+ With no Node 22 or later on PATH, the script installs Node 22.20.0 from
26
+ `nodejs.org` into `~/.local/share/rer/runtimes` (under `XDG_DATA_HOME` when set),
27
+ verifies the tarball against that release's published `SHASUMS256.txt`, and
28
+ prints its location. The launcher uses this private runtime on later runs.
29
+ System Node and other PATH directories are left alone.
30
+
25
31
  No installer edits shell profiles. The canonical launcher is `~/.local/bin/rer`.
26
32
  Installation creates that directory if needed and never writes into another
27
33
  PATH directory. It names any existing `rer` elsewhere on PATH and leaves it
28
34
  unchanged. If `~/.local/bin` is absent from PATH or another command shadows it,
29
35
  it prints one activation line to run in the current shell:
30
- `export PATH="$HOME/.local/bin:$PATH"` (with fish syntax for fish). The launcher runs `node` from
31
- PATH, so a Node upgrade does not break it. A re-run with the same build changes
36
+ `export PATH="$HOME/.local/bin:$PATH"` (with fish syntax for fish). Without a
37
+ private runtime, the launcher uses `node` from PATH. A re-run with the same build changes
32
38
  nothing; a different build is installed beside the current one, the previous one
33
39
  is kept and older ones are removed. It refuses to replace a `~/.local/bin/rer`
34
40
  that it did not write.
@@ -47,11 +53,14 @@ install in place.
47
53
  ### Requirements
48
54
 
49
55
  - macOS or Linux, on x64 or arm64. WSL2 counts as Linux.
50
- - Node 22 or later on PATH; `rer` stops with one line naming the minimum on an
51
- older Node.
52
- - For `install.sh`: `curl` and `tar`.
53
- - For `rer dev` in a checkout: the checkout's own package manager (pnpm for
54
- Run Edit Run seeds).
56
+ - For `install.sh`: `curl`, `tar`, and `shasum` or `sha256sum` when it installs
57
+ Node. macOS includes these tools.
58
+ - For the npm/npx install alternatives: Node 22 or later on PATH.
59
+ - Checkout commands acquire the checkout's pinned Node and pnpm when needed.
60
+ `rer install` also downloads the checkout's Playwright Chromium and headless
61
+ shell for verification; `rer verify` installs missing browser files on first
62
+ need. Downloads print progress. `rer doctor` reports a missing browser and
63
+ directs you to `rer install`, without downloading anything itself.
55
64
 
56
65
  Not supported: native Windows (`install.sh` and `rer` say to use WSL2), and
57
66
  `OPERATIONS.json` version 1 projects.
@@ -0,0 +1,65 @@
1
+ // Browser prerequisites come from the checkout's Playwright, including its
2
+ // platform/revision and PLAYWRIGHT_BROWSERS_PATH handling. Inspection never
3
+ // launches a browser or downloads anything.
4
+ import { access, constants } from 'node:fs/promises';
5
+ import { createRequire } from 'node:module';
6
+ import { dirname, join } from 'node:path';
7
+ import { RerError } from './errors.mjs';
8
+ import { shared } from './shared.mjs';
9
+
10
+ export const browserRepair = 'rer install';
11
+
12
+ export function checkoutPlaywright(root, { required = true } = {}) {
13
+ const require = createRequire(join(root, 'package.json'));
14
+ for (const name of ['playwright-core', '@playwright/test', 'playwright']) {
15
+ let entry;
16
+ try { entry = require.resolve(name); } catch (error) { if (error.code === 'MODULE_NOT_FOUND') continue; throw error; }
17
+ const playwright = require(name);
18
+ if (!playwright.chromium) continue;
19
+ let scope = createRequire(entry);
20
+ if (name === '@playwright/test') scope = createRequire(scope.resolve('playwright'));
21
+ const core = dirname(scope.resolve('playwright-core/package.json'));
22
+ const manifest = scope(join(core, 'package.json'));
23
+ // Playwright's bundled releases export the same registry through coreBundle;
24
+ // older checkout pins keep it in the server module tree.
25
+ const { registry } = manifest.exports?.['./lib/coreBundle']
26
+ ? scope('playwright-core/lib/coreBundle').registry
27
+ : scope(join(core, 'lib/server/registry/index.js'));
28
+ return { name, playwright, registry, cli: join(core, 'cli.js') };
29
+ }
30
+ if (required) throw new RerError('browser_dependency_missing', `The checkout's Playwright is missing. Run ${browserRepair} to install its locked dependencies; verification requires playwright-core, @playwright/test or playwright.`, 3);
31
+ }
32
+
33
+ export async function browserDoctor(root) {
34
+ let resolved;
35
+ try { resolved = checkoutPlaywright(root); }
36
+ catch (error) { return { ok: false, issue: error instanceof RerError ? error.message : `The checkout's Playwright could not be inspected. Run ${browserRepair}.`, fix: browserRepair, executables: [] }; }
37
+ const executables = [];
38
+ for (const name of ['chromium', 'chromium-headless-shell']) {
39
+ // Releases before the separate headless shell use the Chromium executable.
40
+ const executable = resolved.registry.findExecutable(name);
41
+ if (!executable && name === 'chromium-headless-shell') continue;
42
+ const path = executable?.executablePath();
43
+ let ok = false;
44
+ if (path) try { await access(path, process.platform === 'win32' ? constants.F_OK : constants.X_OK); ok = true; } catch {}
45
+ executables.push({ name, ...(path ? { path } : {}), ok });
46
+ }
47
+ const missing = executables.filter(executable => !executable.ok).map(executable => executable.name);
48
+ return { ok: !missing.length, package: resolved.name, executables, ...(missing.length ? { issue: `Playwright browser executables are missing: ${missing.join(', ')}. Run ${browserRepair}.`, fix: browserRepair } : {}) };
49
+ }
50
+
51
+ export async function ensureChromium(root, store, signal, { required = true } = {}) {
52
+ // Installing a first-party adapter without browser dependencies remains valid.
53
+ // Verification requires Playwright; installation provisions it when declared.
54
+ const resolved = checkoutPlaywright(root, { required });
55
+ if (!resolved) return;
56
+ const before = await browserDoctor(root);
57
+ if (before.ok) return;
58
+ const { cli } = resolved;
59
+ const { dependencyEnvironment } = await shared('dependency-environment.mjs');
60
+ const env = dependencyEnvironment();
61
+ if (process.env.PLAYWRIGHT_BROWSERS_PATH !== undefined) env.PLAYWRIGHT_BROWSERS_PATH = process.env.PLAYWRIGHT_BROWSERS_PATH;
62
+ await store.run('Installing Chromium and its headless shell from the checkout’s Playwright', 'pnpm', ['exec', 'node', cli, 'install', 'chromium'], { cwd: root, signal, env });
63
+ const after = await browserDoctor(root);
64
+ if (!after.ok) throw new RerError('browser_install_incomplete', after.issue, 3);
65
+ }
package/cli/demo-host.mjs CHANGED
@@ -20,7 +20,7 @@ export async function demoHostCommand(project, options, store, signal, out, oper
20
20
  if (!(app.platforms ?? ['workers']).includes('container')) throw refuse('A hosted demo runs the seed\'s container image: declare "container" in deploy.json platforms first.');
21
21
  let plan;
22
22
  try { plan = demoPlan({ project: app.project, environment: options.environment ?? 'production', compatibilityDate: app.compatibilityDate, originVar: app.originVar, hostVariables: app.container?.hostVariables, declaration, turnstileSiteKey: process.env.TURNSTILE_SITE_KEY?.trim() }); }
23
- catch (error) { throw invalid(`The demo deploy declaration is invalid (${error.message}). deploy-demo.json holds {"version": 1, "domain": "<run site apex>", "name": "<product name>"}, optionally "maxInstances", "instanceType" (${INSTANCE_TYPES.join(', ')}; default basic) and plain "settings".`); }
23
+ catch (error) { throw invalid(`The demo deploy declaration is invalid (${error.message}). deploy-demo.json holds {"version": 1, "domain": "<run site apex>", "name": "<product name>"}, optionally "maxInstances", "instanceType" (${INSTANCE_TYPES.join(', ')}; default basic), "ownerEmail" (the demo owner's address; default owner@demo.invalid) and plain "settings".`); }
24
24
  if (options.remove) return removeDemo(plan, store, signal);
25
25
  if (process.env.RER_DEMO_OPERATOR_TOKEN && (process.env.RER_DEMO_OPERATOR_TOKEN.length < 32 || process.env.RER_DEMO_OPERATOR_TOKEN.length > 512)) throw invalid('RER_DEMO_OPERATOR_TOKEN must contain 32 to 512 characters.');
26
26
  const folder = join(project.root, '.rer', 'demo-host');
@@ -1,6 +1,7 @@
1
1
  import { observedReadiness } from '../modules/deploy-kit/readiness-window.mjs';
2
2
  // Retry only the bootstrap HTTP exchange, never the hook's other effects. The
3
- // current invocation must prove it uploaded this token to a newly created Worker.
3
+ // current invocation must prove it uploaded this token to a fresh Worker version.
4
+ // The route can still answer 404 after /health first reaches another edge.
4
5
  export async function ownerClaimRequest(fetch, input, init, { deployed, tokenKey = 'SETUP_TOKEN', signal } = {}) {
5
6
  const url = new URL(input instanceof Request ? input.url : input);
6
7
  if (deployed?.origin && url.origin !== deployed.origin) throw new Error('owner-claim-origin-mismatch');
@@ -21,11 +22,11 @@ export async function ownerClaimRequest(fetch, input, init, { deployed, tokenKey
21
22
  const destination = response.headers.get('location');
22
23
  if (destination && new URL(destination, url).origin !== url.origin) throw new Error('owner-claim-origin-mismatch');
23
24
  }
24
- let invalid = false;
25
+ let pending = fresh && !response.redirected && response.status === 404;
25
26
  if (fresh && response.status === 403) {
26
- try { invalid = (await response.clone().json())?.error === 'invalid_setup_token'; } catch {}
27
+ try { pending = (await response.clone().json())?.error === 'invalid_setup_token'; } catch {}
27
28
  }
28
- if (!invalid || window.remaining() <= 0) return response;
29
+ if (!pending || window.remaining() <= 0) return response;
29
30
  await response.body?.cancel();
30
31
  await window.pause();
31
32
  }
@@ -8,14 +8,14 @@ import { deployEnvironment, deployAgain } from './deploy-inputs.mjs';
8
8
  import { claimHostedOwner } from './deploy-owner.mjs';
9
9
  import { checkHostedSetup, hostedSetupFailure } from './deploy-setup.mjs';
10
10
  import { mutationReadinessFailure } from './deploy-readiness.mjs';
11
- import { observeOwner } from './deploy-observation.mjs';
11
+ import { observeOwner, ownerExchangeFailure } from './deploy-observation.mjs';
12
12
  import { committedSource } from './deploy-source.mjs';
13
13
  import { hookOrigin, waitForSource } from './deploy-hook.mjs';
14
14
  import { rememberHookState, hookState } from './deploy-hook-record.mjs';
15
15
  import { main as owner } from '../modules/deploy-kit/owner-cli.mjs';
16
16
  import { localOnlyBinding, ownerWorkerName } from '../modules/deploy-kit/owner.mjs';
17
17
  import { refuseLocalModels } from '../modules/deploy-kit/local-only.mjs';
18
- import { providerRefusal, providerTransport } from '../modules/deploy-kit/diagnostics.mjs';
18
+ import { migrationFailure, providerFailure, assetFailure } from '../modules/deploy-kit/diagnostics.mjs';
19
19
  import { shared } from './shared.mjs';
20
20
 
21
21
  export function validateDeployOptions(options) {
@@ -108,7 +108,7 @@ export async function deployCommand(context) {
108
108
  // current version independently of the original upload's spent deadline.
109
109
  const state = await inspect(origin);
110
110
  if ((state?.origin ?? origin) !== origin || claims.some(item => item.origin !== origin)) throw new Error('owner-claim-origin-mismatch');
111
- if (claims.some(item => !item.outcome)) throw new Error('owner-claim-failed');
111
+ if (claims.some(item => !item.outcome)) { const error = new Error('owner-claim-failed'); error.ownerExchange = claims.find(item => !item.outcome); throw error; }
112
112
  claimed = claims.at(-1)?.outcome;
113
113
  step = 'wait for the deployed source';
114
114
  await waitForSource({ origin, sourceSha, versionId: state?.versionId ?? (!claims.length && !deployed.owner ? uploaded?.versionId : undefined), again: deployAgain(options) });
@@ -136,7 +136,9 @@ export async function deployCommand(context) {
136
136
  if (setup) throw commandFailure(redact(setup));
137
137
  const readiness = mutationReadinessFailure(error, { again, redact });
138
138
  if (readiness) throw commandFailure(readiness);
139
- const refused = providerRefusal(error) ?? providerTransport(error);
140
- throw commandFailure(redact(`${state} Failed at ${step}: ${error.message}${refused ? ` (${refused})` : ''}${error.cause ? ` (${error.cause})` : ''}. Fix the cause and run ${again} again using the same environment credentials. ${outcome && recorded ? `To retire the token without rebuilding: ${again} --unset-secret ${setupManifest?.steps?.find(item => item.type === 'owner-claim')?.tokenField ?? 'SETUP_TOKEN'}.` : ''}`));
139
+ const refused = [providerFailure(error,redact), assetFailure(error)].filter(Boolean).join('; '), migration = migrationFailure(error, again);
140
+ const exchange = error.ownerExchange ?? (error.message === 'owner-claim-failed' ? observedClaims.lastExchange ?? observedClaims.at(-1) : undefined);
141
+ const ownerCause = ownerExchangeFailure(exchange);
142
+ throw commandFailure(redact(`${state} Failed at ${step}: ${error.message}${refused ? ` (${refused})` : ''}${ownerCause ? ` (${ownerCause})` : ''}${error.cause ? ` (${error.cause})` : ''}.${migration ? ` ${migration}` : ''} Fix the cause and run ${again} again using the same environment credentials. ${outcome && recorded ? `To retire the token without rebuilding: ${again} --unset-secret ${setupManifest?.steps?.find(item => item.type === 'owner-claim')?.tokenField ?? 'SETUP_TOKEN'}.` : ''}`));
141
143
  }
142
144
  }
@@ -1,4 +1,5 @@
1
1
  import { randomBytes } from 'node:crypto';
2
+ import { relative } from 'node:path';
2
3
  import { shared } from './shared.mjs';
3
4
  import { invalid } from './errors.mjs';
4
5
  import { readDeployEnvFile } from '../modules/deploy-kit/env-file.mjs';
@@ -54,5 +55,5 @@ export async function withDeployEnvironment(root, options, run) {
54
55
 
55
56
  export function deployAgain(options) {
56
57
  const quote = value => /^[a-zA-Z0-9_./-]+$/.test(value) ? value : `'${String(value).replaceAll("'", "'\"'\"'")}'`;
57
- return `rer deploy --environment ${quote(options.environment ?? 'production')}${options.envFile ? ` --env-file ${quote(options.envFile)}` : ''}${options.cwd ? ` --cwd ${quote(options.cwd)}` : ''}`;
58
+ return `rer deploy --environment ${quote(options.environment ?? 'production')}${options.envFile ? ` --env-file ${quote(options.envFile)}` : ''}${options.cwd ? ` --cwd ${quote(relative(process.cwd(), options.cwd) || '.')}` : ''}`;
58
59
  }
@@ -12,7 +12,11 @@ export async function observeOwner({ paths, inspect, beforeClaim, addSecret, dep
12
12
  if (paths.includes(url.pathname) && (init.method ?? (input instanceof Request ? input.method : 'GET')).toUpperCase() === 'POST') {
13
13
  try { body = JSON.parse(typeof init.body === 'string' ? init.body : input instanceof Request ? await input.clone().text() : 'null'); } catch {}
14
14
  }
15
- if (typeof body?.token !== 'string' || !body.token) return fetch(input, init);
15
+ if (typeof body?.token !== 'string' || !body.token) {
16
+ const response = await fetch(input,init);
17
+ if (claims.some(item => item.origin === url.origin)) claims.lastExchange = await exchange(response,url,init.method ?? 'GET');
18
+ return response;
19
+ }
16
20
  addSecret(body.token);
17
21
  const deployed = await inspect(url.origin);
18
22
  if (deployed && url.origin !== deployed.origin) throw new Error('owner-claim-origin-mismatch');
@@ -24,9 +28,23 @@ export async function observeOwner({ paths, inspect, beforeClaim, addSecret, dep
24
28
  try { code = (await response.clone().json()).error; } catch {}
25
29
  }
26
30
  const outcome = response.status === 303 ? 'claimed' : response.status === 409 && code === 'already_initialized' ? 'kept' : undefined;
27
- claims.push({ origin: url.origin, outcome, status: response.status });
31
+ const observed = {...await exchange(response,url,'POST'),outcome};
32
+ claims.push(observed); claims.lastExchange = observed;
28
33
  return response;
29
34
  };
30
35
  try { return await observeReadiness(() => run(claims)); }
31
36
  finally { globalThis.fetch = fetch; }
32
37
  }
38
+
39
+ async function exchange(response,url,method) {
40
+ let code;
41
+ if (response.status >= 400) { try { code = (await response.clone().json()).error; } catch {} }
42
+ return {origin:url.origin,path:url.pathname,method,status:response.status,
43
+ ...(typeof code === 'string' && /^[a-zA-Z0-9_-]{1,80}$/.test(code) ? {code} : {}),
44
+ ...(response.status === 303 && !response.headers.has('set-cookie') ? {missingCookie:true} : {})};
45
+ }
46
+
47
+ export function ownerExchangeFailure(exchange) {
48
+ if (!exchange || typeof exchange.path !== 'string' || !Number.isInteger(exchange.status)) return undefined;
49
+ return `${exchange.method === 'GET' ? 'GET' : 'POST'} ${exchange.path.split('?')[0]} returned HTTP ${exchange.status}${exchange.code ? ` (${exchange.code})` : ''}${exchange.missingCookie ? ' (no Set-Cookie header)' : ''}`;
50
+ }
@@ -1,5 +1,5 @@
1
1
  import { ownerClaimRequest } from './deploy-claim-request.mjs';
2
- import { observeOwner } from './deploy-observation.mjs';
2
+ import { observeOwner, ownerExchangeFailure } from './deploy-observation.mjs';
3
3
  import { randomBytes } from 'node:crypto';
4
4
 
5
5
  // After a healthy deploy, the hosted app's first owner is the setup owner: rer
@@ -28,7 +28,7 @@ export async function claimHostedOwner({ hook, setupManifest, declaration, deplo
28
28
  try { if (!deployed.ownerClaim) await recordClaim?.(outcome); await secret(['--unset', tokenKey], env); }
29
29
  catch (cause) {
30
30
  if (cause.secretChange) { cause.owner = outcome; cause.tokenKey = tokenKey; cause.ownerFinalization = true; throw cause; }
31
- const error = new Error('owner-token-retirement-failed'); error.owner = outcome; error.tokenKey = tokenKey; error.cause = cause.message; throw error; }
31
+ const error = new Error('owner-token-retirement-failed'); error.owner = outcome; error.tokenKey = tokenKey; error.cause = cause; throw error; }
32
32
  return outcome;
33
33
  };
34
34
  // Only a recorded successful bootstrap proves ownership; --unset-secret alone
@@ -53,11 +53,16 @@ export async function claimHostedOwner({ hook, setupManifest, declaration, deplo
53
53
  }
54
54
  if (typeof hook === 'function') {
55
55
  const context = { origin: deployed.origin, vars: { ...env, [tokenKey]: token }, input: {}, store, signal, ownerClaim: claim, fail: () => ownerFailure('the seed owner hook failed') };
56
- let observed;
56
+ let observed, exchanges = [];
57
57
  try {
58
58
  if (deployed.observedOwner) await hook(context);
59
- else await observeOwner({ paths: ['/auth/bootstrap', claim?.path].filter(Boolean), inspect, addSecret, deployed: () => deployed, tokenKey }, async claims => { await hook(context); observed = claims.at(-1)?.outcome; });
60
- } catch (cause) { if (cause.message === 'owner-claim-failed') throw cause; throw ownerFailure(cause.message); }
59
+ else await observeOwner({ paths: ['/auth/bootstrap', claim?.path].filter(Boolean), inspect, addSecret, deployed: () => deployed, tokenKey }, async claims => { exchanges = claims; await hook(context); observed = claims.at(-1)?.outcome; });
60
+ } catch (cause) {
61
+ const exchange = exchanges.lastExchange ?? exchanges.at(-1);
62
+ const error = cause.message === 'owner-claim-failed' ? cause : ownerFailure(cause.message);
63
+ if (exchange) { error.ownerExchange = exchange; error.cause = ownerExchangeFailure(exchange); }
64
+ throw error;
65
+ }
61
66
  // Function hooks can keep existing owners without returning a value. Observe
62
67
  // their actual response, instead of assuming that a resolved promise claimed.
63
68
  const outcome = context.ownerClaimed ?? observed ?? deployed.observedOwner?.();
@@ -69,12 +74,12 @@ export async function claimHostedOwner({ hook, setupManifest, declaration, deplo
69
74
  try {
70
75
  response = await ownerClaimRequest(fetch, new URL(hook.path ?? '/auth/bootstrap', deployed.origin), { method: 'POST',
71
76
  headers: { Origin: deployed.origin, 'Content-Type': 'application/json' }, body: JSON.stringify({ token, displayName, returnTo: hook.returnTo ?? '/' }) }, {deployed, tokenKey, signal});
72
- } catch (error) { throw ownerFailure(['owner-claim-origin-mismatch','owner-claim-redirected','owner-claim-readiness-timeout'].includes(error.message) ? error.message : 'the hosted application did not answer'); }
77
+ } catch (error) { throw ownerFailure(`POST ${new URL(hook.path ?? '/auth/bootstrap',deployed.origin).pathname}: ` + (['owner-claim-origin-mismatch','owner-claim-redirected','owner-claim-readiness-timeout'].includes(error.message) ? error.message : 'the hosted application did not answer')); }
73
78
  if (response.status !== 303) { try { const body = await response.json(); if (typeof body?.error === 'string' && /^[a-z_]{1,64}$/.test(body.error)) code = body.error; } catch {} }
74
79
  else await response.body?.cancel();
75
80
  const outcome = response.status === 303 ? 'claimed' : response.status === 409 && code === 'already_initialized' ? 'kept' : undefined;
76
81
  const advice = code !== 'invalid_setup_token' ? '' : !secret ? `; the Worker holds another setup token: have the deploy hook return the one it deployed as setupToken, or set it as ${item.environment} with --env-file` : given ? `; the ${item.environment} you supplied is not the deployed setup token: leave it unset and rer issues a fresh one` : '';
77
- if (!outcome) throw ownerFailure(`HTTP ${response.status} (${code})${advice}`);
82
+ if (!outcome) throw ownerFailure(`POST ${new URL(hook.path ?? '/auth/bootstrap',deployed.origin).pathname} returned HTTP ${response.status} (${code})${advice}`);
78
83
  return retire(outcome);
79
84
  }
80
85
 
package/cli/deploy.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { requireProductionAuth } from './production-auth.mjs';
2
2
  import { readFile } from 'node:fs/promises';
3
- import { deployDiagnostic, providerTransport } from '../modules/deploy-kit/diagnostics.mjs';
3
+ import { deployDiagnostic, migrationFailure, providerFailure, assetFailure } from '../modules/deploy-kit/diagnostics.mjs';
4
4
  import { shared } from './shared.mjs';
5
5
  import { contained } from './project.mjs';
6
6
  import { missing, invalid, refuse, RerError } from './errors.mjs';
@@ -110,6 +110,15 @@ export function ownerDeploy(declarationPath, lifecycle) {
110
110
 
111
111
  // The failing step, its redacted cause, what this run created and the command that continues.
112
112
  function failureText({ error, step, created, again, retry, secretChange, deployed, redact }) {
113
+ if (step === 'remove') {
114
+ const remaining = error.remaining;
115
+ if (error.message === 'nothing-to-remove') return `There are no recorded resources to remove; nothing was removed.`;
116
+ const cause = deployDiagnostic(error, redact)?.code ?? error.message;
117
+ const count = Array.isArray(remaining) ? `${remaining.length} resources remain (${remaining.join(', ') || 'none'})` : 'the remaining resource count could not be read';
118
+ const detail = providerFailure(error, redact);
119
+ const failed = error.failed?.map(item => `${item.resource}: ${providerFailure(item.error, redact) ?? item.code}`).join('; ');
120
+ return redact(`Removal failed: ${count}; run ${retry} again. Cause: ${cause}${detail ? ` (${detail})` : ''}${failed ? `; ${failed}` : ''}.`);
121
+ }
113
122
  const setup = hostedSetupFailure(error, { origin: deployed?.origin, again });
114
123
  if (setup) return redact(setup);
115
124
  const readiness = mutationReadinessFailure(error, { again, redact });
@@ -119,23 +128,27 @@ function failureText({ error, step, created, again, retry, secretChange, deploye
119
128
  const at = step === 'deploy' ? diagnostic?.step ?? 'prepare deploy' : step;
120
129
  const input = /^missing-secret-([A-Z][A-Z0-9_]*)$/.exec(code)?.[1];
121
130
  if (input) return `Deploy needs ${input}, which the deploy declaration lists as a secret and the Worker does not hold it. Set ${input} in the environment or in an --env-file file (an owned 0600 file of KEY=VALUE lines), then run the same command again. Nothing was uploaded.${created.length ? ` Resources created this attempt: ${created.join(', ')}.` : ''}`;
122
- if (code === 'remove-incomplete') return `Removal stopped with ${error.remaining.join(', ')} still present${error.failed.length ? ` (${error.failed.map(item => `${item.resource}: ${item.code}`).join('; ')})` : ''}. Removed: ${error.removed.join(', ') || 'nothing'}. Confirmed owned R2 buckets are emptied automatically; unproved buckets are never purged. Run ${again} --remove --yes again to finish.`;
123
131
  if (code === 'nothing-to-remove') return `The deployment record selected by ${again} has no resources that rer owns, so --remove deletes nothing.`;
124
- if (code === 'owner-token-retirement-failed') return `The application is deployed at ${deployed?.origin}; owner ${error.owner}; setup token retirement failed (${redact(String(error.cause))}). Run ${again} --unset-secret ${error.tokenKey ?? 'SETUP_TOKEN'} using the same environment credentials, or run ${again} again to finish.`;
132
+ if (code === 'owner-token-retirement-failed') return `The application is deployed at ${deployed?.origin}; owner ${error.owner}; setup token retirement failed (${redact(String(error.cause))}${providerFailure(error,redact) ? `; ${providerFailure(error,redact)}` : ''}). Run ${again} --unset-secret ${error.tokenKey ?? 'SETUP_TOKEN'} using the same environment credentials, or run ${again} again to finish.`;
125
133
  if (code === 'owner-claim-failed') return `The application is deployed at ${deployed?.origin}, but claiming its owner failed: ${redact(String(error.cause))}. Owner claim and setup token retirement are not confirmed; run ${again} again using the same environment credentials to finish.`;
126
134
  const resource = diagnostic?.resource ?? (error.resource ? redact(String(error.resource)) : undefined);
127
135
  if (code === 'resource-not-listed') return `Deploy stopped at ${at}: ${resource} was created, but Cloudflare's account listing still does not show it after two minutes. Nothing was uploaded.\nResources created this attempt: ${created.join(', ') || 'none'}.\nRun ${again} again once the listing catches up: it reuses ${resource}. To delete what this environment created instead: ${again} --remove --yes.`;
128
136
  const lines = [`Deploy failed at ${at}: ${code}${resource ? ` (${resource})` : ''}${diagnostic?.providerCodes?.length ? ` (provider ${diagnostic.providerCodes.join(', ')})` : ''}.`];
129
- const transport = providerTransport(error, redact);
137
+ const asset = assetFailure(error, redact);
138
+ if (asset) lines.push(`${asset}.`);
139
+ const transport = providerFailure(error, redact);
130
140
  if (transport) lines.push(`${transport}.`);
131
141
  if (diagnostic?.output && diagnostic.output !== '(no provider output)') lines.push(`First redacted output lines:\n${diagnostic.output}`);
132
142
  lines.push(`Resources created this attempt: ${created.join(', ') || 'none'}.`);
133
- lines.push(recovery({ code, at, resource, again, retry, secretChange }));
143
+ const migration = migrationFailure(error, again);
144
+ if (migration) lines.push(redact(migration));
145
+ if (code !== 'uncertain-migration-claim') lines.push(recovery({ code, at, resource, again, retry, secretChange }));
134
146
  return lines.join('\n');
135
147
  }
136
148
 
137
149
  function recovery({ code, at, resource, again, retry, secretChange }) {
138
150
  const remove = `${again} --remove --yes`, removing = retry === remove;
151
+ if (code === 'provider-incomplete-pagination') return `Cloudflare did not supply a complete list. Inspect the named GET call in Cloudflare, resolve its missing continuation, then run ${retry} again with the same account and environment. Keep the deployment record so rer can reuse its resources.`;
139
152
  if (code === 'owned-resource-replaced' || code === 'resource-name-collision') return `rer refuses to change a resource it did not create or that was replaced after it did; nothing was changed. Choose another --environment name, or remove the other resource yourself.`;
140
153
  // A lost create answer: the resource may exist, and rer cannot prove it made it.
141
154
  if (resource && (code === 'uncertain-resource-create' || code === 'provider-transport-failed' && at.startsWith('create '))) {
@@ -144,7 +157,7 @@ function recovery({ code, at, resource, again, retry, secretChange }) {
144
157
  }
145
158
  if (code === 'uncertain-resource-not-empty') return `Possibly created: ${resource}, but it holds data, so it may not be the one rer's interrupted run made and rer will not delete it. Inspect it in the Cloudflare dashboard; delete it yourself only if its data is disposable, then run ${retry} again.`;
146
159
  if (code === 'uncertain-resource-unverifiable') return `Possibly created: ${resource}. rer cannot read whether a queue holds messages, so it will not delete it. Inspect it in the Cloudflare dashboard: if it is the empty one from the interrupted run, delete it, then run ${retry} again.`;
147
- if (code === 'changed-or-uncertain-migration-history') return `${resource ?? 'A D1 database'} holds a migration rer started but could not confirm, or one changed since it was applied; rer never retries or guesses a migration. Inspect it in the Cloudflare dashboard: if it is the empty one from this interrupted first deploy, delete it with ${remove} (that deletes everything this environment created), then run ${again} again. If it holds data, resolve the interrupted migration by hand first (deploy-kit README, Migration safety).`;
160
+ if (code === 'changed-or-uncertain-migration-history') return `${resource ?? 'A D1 database'} holds migration history this build does not match: a migration changed or missing since it was applied, or an unconfirmed one that is not this build's next migration; rer never guesses migration history. Inspect it in the Cloudflare dashboard: if it is the empty one from this interrupted first deploy, delete it with ${remove} (that deletes everything this environment created), then run ${again} again. If it holds data, resolve the interrupted migration by hand first (deploy-kit README, Migration safety).`;
148
161
  if (removing) return `Fix the cause, then run ${retry} again.`;
149
162
  if (secretChange) return `Fix the cause, then run ${retry} again; a plain ${again} does not make this change.`;
150
163
  return `Fix the cause, then run ${again} again: it continues with what was created. To delete what this environment created instead: ${remove}.`;
package/cli/export.mjs CHANGED
@@ -6,7 +6,7 @@ import { cliVersion } from './version.mjs';
6
6
 
7
7
  // Copy whole maintained source/tooling directories. Python publication scans
8
8
  // load sibling modules and data dynamically; they belong in the inventory too.
9
- export const sourceRoots = ['bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/delivery-producer/migrations.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs'];
9
+ export const sourceRoots = ['bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/delivery-producer/migrations.mjs', 'modules/delivery-producer/mail.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs'];
10
10
  export async function inventory(base, roots = sourceRoots) {
11
11
  const files = [];
12
12
  async function walk(path) {
@@ -1,24 +1,18 @@
1
1
  // Chromium from the seed's own Playwright, the two ways of serving pages to it
2
2
  // (the production build as rer deploy hosts it, or a running origin), and one
3
3
  // load: scripts held until the probe releases them, every external request aborted.
4
- import { createRequire } from 'node:module';
5
- import { join } from 'node:path';
4
+ import { checkoutPlaywright, browserRepair } from '../browser-runtime.mjs';
6
5
  import { RerError } from '../errors.mjs';
7
6
  import { serveHosted } from '../hosted-output.mjs';
8
7
  import { probe } from './probe.mjs';
9
8
  import { cloudflareRewrite } from './cases.mjs';
10
9
 
11
- const INSTALL = 'pnpm exec playwright install chromium';
12
-
13
10
  export async function launchChromium(root) {
14
- const require = createRequire(join(root, 'package.json'));
15
- let playwright, name;
16
- for (const candidate of ['playwright-core', '@playwright/test', 'playwright']) { try { playwright = require(candidate); name = candidate; break; } catch {} }
17
- if (!playwright?.chromium) throw new RerError('hydration_browser_missing', `The hydration check runs Chromium through the seed's own Playwright, and none of playwright-core, @playwright/test or playwright resolves from ${join(root, 'package.json')}. Add @playwright/test to devDependencies, install, then run ${INSTALL}.`, 1);
11
+ const { playwright, name } = checkoutPlaywright(root);
18
12
  // Pages fulfilled by the check would otherwise count as public, and Chromium would
19
13
  // refuse a dev server's loopback HMR socket from them.
20
14
  try { return await playwright.chromium.launch({ args: ['--disable-features=LocalNetworkAccessChecks'] }); }
21
- catch (error) { throw new RerError('hydration_browser_missing', `The hydration check could not start Chromium from the seed's ${name}: ${String(error.message).split('\n').find(line => line.trim()) ?? error}. Install the browser it pins with ${INSTALL}.`, 1); }
15
+ catch (error) { throw new RerError('hydration_browser_missing', `The hydration check could not start Chromium from the seed's ${name}: ${String(error.message).split('\n').find(line => line.trim()) ?? error}. Install the browser it pins with ${browserRepair}.`, 1); }
22
16
  }
23
17
 
24
18
  const strip = new Set(['content-encoding', 'content-length', 'transfer-encoding', 'connection']);
package/cli/inspect.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { browserDoctor } from './browser-runtime.mjs';
1
2
  import { dependencyDoctor } from './dependency-doctor.mjs';
2
3
  import { inventory } from './export.mjs';
3
4
  import { lstat, readFile } from 'node:fs/promises';
@@ -185,12 +186,13 @@ export async function doctor(project, store, signal) {
185
186
  if (directory) { usePnpm(directory); try { pnpm = await probePnpm(project.root, store, signal); pnpmIssues.length = 0; } catch (error) { if (signal?.aborted) throw error; pnpmIssues.push(store.redact(error.message)); } }
186
187
  }
187
188
  }
189
+ const browser = project.profile === 'first-party' ? await browserDoctor(project.root) : undefined;
188
190
  const aiIssues = await localAiDiagnostics(project,process.env);
189
191
  const dependencies=project.profile==='first-party'?await dependencyDoctor(project.root):[];
190
192
  const expectedNode = await projectNodePin(project.root);
191
193
  const inputs = project.profile === 'first-party' ? requiredLocalSettings(project, values) : [];
192
194
  const warnings = project.profile === 'first-party' ? await cacheWarnings(project.root) : [];
193
- return { dependencies, warnings, operations: diagnostic, ok: !aiIssues.length && dependencies.every(d=>d.ok) && diagnostic.ok && stateValid && !inputs.length && (project.profile !== 'first-party' || (Boolean(expectedPnpm) && process.versions.node === expectedNode && pnpm === expectedPnpm)),
195
+ return { dependencies, warnings, browser, operations: diagnostic, ok: browser?.ok !== false && !aiIssues.length && dependencies.every(d=>d.ok) && diagnostic.ok && stateValid && !inputs.length && (project.profile !== 'first-party' || (Boolean(expectedPnpm) && process.versions.node === expectedNode && pnpm === expectedPnpm)),
194
196
  node: { actual: process.versions.node, expected: expectedNode },
195
197
  pnpm: project.profile === 'first-party' ? { actual: pnpm, expected: expectedPnpm ?? null, ...(pnpmIssues.length ? { issue: [...new Set(pnpmIssues)].join('\n') } : {}) } : undefined,
196
198
  ai: { issues: aiIssues },
package/cli/lifecycle.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { ensureChromium } from './browser-runtime.mjs';
1
2
  import { dependencyInputs } from './dependency-input.mjs';
2
3
  import { linkDependencies } from './dependencies.mjs';
3
4
  import { savedSetupAnswers } from './setup-answers.mjs';
@@ -86,11 +87,13 @@ async function runLifecycle(project, options, out, deployRedaction) {
86
87
  if (options.verb === 'deploy' && options.demo) return await (await import('./demo-host.mjs')).demoHostCommand(project, options, store, signal, out, operation);
87
88
  if (options.verb === 'install') {
88
89
  const { dependencyEnvironment } = await shared('dependency-environment.mjs');
89
- await store.run('Installing frozen dependencies', 'pnpm', ['install', '--frozen-lockfile'], { cwd: project.root, signal, env: { ...dependencyEnvironment(), CI: 'true' } }); return {};
90
+ await store.run('Installing frozen dependencies', 'pnpm', ['install', '--frozen-lockfile'], { cwd: project.root, signal, env: { ...dependencyEnvironment(), CI: 'true' } });
91
+ await ensureChromium(project.root, store, signal, { required: false }); return {};
90
92
  }
91
93
  if (options.verb === 'verify') {
92
94
  const target = adapter.verify;
93
95
  if (!Array.isArray(target)) throw refuse('A complete internal verification target is missing.');
96
+ await ensureChromium(project.root, store, signal);
94
97
  await store.run('Verifying application', target[0], target[1], { cwd: project.root, signal, env: { ...process.env, RER_LOCAL_OPERATION: operation.token } });
95
98
  await store.step('Serving the production build as rer deploy hosts it');
96
99
  const declaration = adapter.deployDeclaration ?? adapter.deploy?.declaration;
package/cli/site.mjs CHANGED
@@ -113,7 +113,7 @@ export async function siteCommand(project, options, store, signal, out) {
113
113
  if (!options.json) for (const line of human) out.human(line);
114
114
  const { cloudflare } = await import('../modules/deploy-kit/provider.mjs');
115
115
  const { collectFiles } = await import('../modules/deploy-kit/artifact.mjs');
116
- const { siteDeploy } = await import('../modules/deploy-kit/site.mjs');
116
+ const { siteDeploy, siteReadbackSummary } = await import('../modules/deploy-kit/site.mjs');
117
117
  const environment = options.environment ?? 'production';
118
118
  try {
119
119
  const api = cloudflare({ accountId: process.env.CLOUDFLARE_ACCOUNT_ID, token: process.env.CLOUDFLARE_API_TOKEN });
@@ -122,7 +122,7 @@ export async function siteCommand(project, options, store, signal, out) {
122
122
  return { dryRun: false, deployed: true, origin: result.origin, site: summary };
123
123
  } catch (error) {
124
124
  if (error instanceof RerError) throw error;
125
- throw new RerError('deploy_refused', `Run site deploy stopped: ${/^[a-z0-9-]{1,80}$/.test(error.message) ? error.message : 'site-deploy-failed'}${error.resource ? ` (${error.resource})` : ''}.`, 1);
125
+ throw new RerError('deploy_refused', `Run site deploy stopped: ${/^[a-z0-9-]{1,80}$/.test(error.message) ? error.message : 'site-deploy-failed'}${error.resource ? ` (${error.resource})` : ''}.${siteReadbackSummary(error)}`, 1);
126
126
  }
127
127
  }
128
128
 
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.25
4
+
5
+ - Invitations stay valid for seven days (`invitationSeconds`), separately from sign-in and step-up links, which keep their short lifetime.
6
+ - Demo and Dev title suffixes are added once, including for missing, empty and suffix-only titles.
7
+ - The shell installer acquires checksum-verified Node 22 in rer's private prefix when needed, leaving system tools alone. The launcher keeps using it without Node on PATH. `rer install` and `rer verify` acquire the checkout's Playwright Chromium and headless shell; `rer doctor` reports missing browser files with `rer install` as the fix, including through the global command for older checkout pins.
8
+ - Portability imports stage their writes in batches within D1's transport budget, with a durable cursor, so populated archives no longer hit `D1_RPC_TRANSPORT_LIMIT`. A same-hash retry resumes an interrupted part, and conflicting content is refused.
9
+ - On a fresh hosted deployment, the owner claim waits through a new route that still answers 404, within the upload propagation window. Asset uploads and checks replay a transient asset failure once; a final asset failure names the asset and its HTTP status.
10
+ - Environment removal retries transient provider 5xx responses within its deadline. A failed removal names the resources still present or not confirmed absent, and gives the same command to finish.
11
+ - Demo image builds accept `MAIL_PROVIDER` and `MAIL_FROM` as public configuration when the managed-mail spec declares them public. Credentials as image variables are still refused.
12
+ - A migration whose D1 import failed is retried by the next deploy of the same bytes, once rer proves none of it applied. Otherwise it stays refused as `uncertain-migration-claim`, and `rer deploy` names the migration, what is present and the exact recovery step.
13
+ - A failed D1 import keeps Cloudflare's codes and messages (credentials and URLs removed, 300 characters each) and names the migration it was running.
14
+ - The deployment spec emits the optional `surfaces.app.signIn` and `nativeExport` declarations from packaging `artifact.specInputs`, using platform's field rules.
15
+ - The owner-claim recovery command prints a relative cwd.
16
+ - The import-kit security test's fixture token now starts with `synthetic-` (`modules/import-kit/tests/readers/security.test.ts`), so credential scans no longer match it.
17
+
18
+ ### Upgrade notes
19
+
20
+ - Update the exact rer package pin, or refresh vendored operating commands, to receive these changes.
21
+ - A deployment stuck at `changed-or-uncertain-migration-history` because its last migration stayed `applying` after a failed import recovers with a plain `rer deploy` of the same build, when that migration's effects are absent.
22
+ - Remove `MAIL_PROVIDER` and `MAIL_FROM` from `deploy.json` secrets and keep them as public spec or Wrangler variables.
23
+
24
+ ## 0.2.24
25
+
26
+ - Hosted demos stay up through redeploys. The demo's Container application keeps a live demo's instance for an hour (`rollout_active_grace_period`), so a deploy that changes the image, instance type or limit no longer ends idle visitors' demos ("This demo has ended" within two minutes before).
27
+ - Hosted demos wait out Cloudflare placement. A fresh application keeps 7 prepared instances; the eighth concurrent demo waited 16-37 s for Cloudflare to place another. Placement waits now renew the 45-second boot budget up to 90 seconds and keep the visitor's reservation. The application's own `max_instances` is twice `maxInstances`, so instances Cloudflare still counts after demos end never refuse an admitted visitor; admission still holds at `maxInstances`.
28
+ - A new demo copy that takes over two seconds to answer is a pending start instead of a 502, and a slow status read stays pending instead of a 503.
29
+ - The start page signs in about half a second sooner: each status poll is held until the start changes, and the reservation is extended alongside the owner claim.
30
+ - `deploy-demo.json` takes an optional `ownerEmail`, the address the demo's owner signs in as and seed screens show (`owner@demo.invalid` unless set).
31
+ - Each demo admission logs `demo_admitted` with the user agent and network, so a held place can be joined to whoever started it. On test hosts, automated browsers pass Turnstile's always-pass testing keys and hold real places.
32
+ - Run-site deploys wait through Cloudflare propagation after a fresh upload, within a 90-second window, and name the serving and newest versions on a timeout.
33
+ - Every Cloudflare list read shares one pagination reader; an incomplete list stops with `provider-incomplete-pagination` instead of treating a resource as absent. Environment removal detaches queue consumers before deleting queues and confirms their absence.
34
+
35
+ ### Upgrade notes
36
+
37
+ - Redeploy the hosted demo (`rer deploy --demo`) once to apply the hour-long rollout grace and the doubled provider limit. The deploy that first sets the grace may itself still replace live demos, so run it when no visitor is mid-demo.
38
+ - Add `"ownerEmail"` to `deploy-demo.json` for a plausible owner address on demo screens.
39
+
3
40
  ## 0.2.23
4
41
 
5
42
  - Managed mail (`rer` provider) works from Cloudflare Workers. Mail transport always fetches with `redirect: 'manual'`, because Workers reject `redirect: 'error'`, which made every relay send end as `transport_uncertain` without a request. A relay 3xx is never followed and is reported as `rejected` (`provider_redirected`).
package/global/README.md CHANGED
@@ -22,13 +22,19 @@ refuses archives with absolute paths, `..` entries, links or devices, then runs
22
22
  the package's own `rer cli install`. A failed or refused download leaves the
23
23
  version you had selected.
24
24
 
25
+ With no Node 22 or later on PATH, the script installs Node 22.20.0 from
26
+ `nodejs.org` into `~/.local/share/rer/runtimes` (under `XDG_DATA_HOME` when set),
27
+ verifies the tarball against that release's published `SHASUMS256.txt`, and
28
+ prints its location. The launcher uses this private runtime on later runs.
29
+ System Node and other PATH directories are left alone.
30
+
25
31
  No installer edits shell profiles. The canonical launcher is `~/.local/bin/rer`.
26
32
  Installation creates that directory if needed and never writes into another
27
33
  PATH directory. It names any existing `rer` elsewhere on PATH and leaves it
28
34
  unchanged. If `~/.local/bin` is absent from PATH or another command shadows it,
29
35
  it prints one activation line to run in the current shell:
30
- `export PATH="$HOME/.local/bin:$PATH"` (with fish syntax for fish). The launcher runs `node` from
31
- PATH, so a Node upgrade does not break it. A re-run with the same build changes
36
+ `export PATH="$HOME/.local/bin:$PATH"` (with fish syntax for fish). Without a
37
+ private runtime, the launcher uses `node` from PATH. A re-run with the same build changes
32
38
  nothing; a different build is installed beside the current one, the previous one
33
39
  is kept and older ones are removed. It refuses to replace a `~/.local/bin/rer`
34
40
  that it did not write.
@@ -47,11 +53,14 @@ install in place.
47
53
  ### Requirements
48
54
 
49
55
  - macOS or Linux, on x64 or arm64. WSL2 counts as Linux.
50
- - Node 22 or later on PATH; `rer` stops with one line naming the minimum on an
51
- older Node.
52
- - For `install.sh`: `curl` and `tar`.
53
- - For `rer dev` in a checkout: the checkout's own package manager (pnpm for
54
- Run Edit Run seeds).
56
+ - For `install.sh`: `curl`, `tar`, and `shasum` or `sha256sum` when it installs
57
+ Node. macOS includes these tools.
58
+ - For the npm/npx install alternatives: Node 22 or later on PATH.
59
+ - Checkout commands acquire the checkout's pinned Node and pnpm when needed.
60
+ `rer install` also downloads the checkout's Playwright Chromium and headless
61
+ shell for verification; `rer verify` installs missing browser files on first
62
+ need. Downloads print progress. `rer doctor` reports a missing browser and
63
+ directs you to `rer install`, without downloading anything itself.
55
64
 
56
65
  Not supported: native Windows (`install.sh` and `rer` say to use WSL2), and
57
66
  `OPERATIONS.json` version 1 projects.
@@ -0,0 +1,45 @@
1
+ // An older checkout pin still runs its own verbs. The installed launcher
2
+ // supplies the browser prerequisite those pins did not yet provision.
3
+ import { mkdtemp, rm } from 'node:fs/promises';
4
+ import { tmpdir } from 'node:os';
5
+ import { join } from 'node:path';
6
+ import { browserDoctor, ensureChromium } from '../cli/browser-runtime.mjs';
7
+ import { output } from '../cli/output.mjs';
8
+ import { RerError } from '../cli/errors.mjs';
9
+ import { shared } from '../cli/shared.mjs';
10
+
11
+ export async function browserPreflight(root, argv) {
12
+ const verb = argv[0], out = output({ verb, json: argv.includes('--json') });
13
+ if (verb === 'doctor') {
14
+ const browser = await browserDoctor(root);
15
+ if (browser.ok) return;
16
+ const diagnostics = { browser, ok: false, scope: 'browser-prerequisite' };
17
+ if (!argv.includes('--json')) out.human(JSON.stringify(diagnostics, null, 2));
18
+ out.result(false, 3, { diagnostics });
19
+ return 3;
20
+ }
21
+ const cancellation = new AbortController();
22
+ let directory, store, termination;
23
+ const handlers = new Map(['SIGINT', 'SIGTERM'].map(name => [name, () => { termination ??= name; cancellation.abort(name); }]));
24
+ for (const [name, handler] of handlers) process.on(name, handler);
25
+ try {
26
+ directory = await mkdtemp(join(tmpdir(), 'rer-browser-'));
27
+ const { createCommands } = await shared('commands.mjs');
28
+ store = await createCommands(directory, { logs: [] }, { terminal: text => out.progress(text) });
29
+ store.setCommandSignal(cancellation.signal);
30
+ // A fresh vendored pin installs its own dependencies; verify will acquire
31
+ // their browser on first need. Package pins have already been bootstrapped.
32
+ await ensureChromium(root, store, cancellation.signal, { required: verb === 'verify' });
33
+ } catch (error) {
34
+ const failure = error instanceof RerError ? error : new RerError('browser_install_failed', `The checkout's Chromium installation failed. Run rer install to retry; inspect the browser download progress for the cause.`, 1);
35
+ if (termination) { failure.exitCode = termination === 'SIGINT' ? 130 : 143; failure.message = `Stopped by ${termination} after owned children were stopped.`; }
36
+ out.error(failure); out.result(false, failure.exitCode);
37
+ return failure.exitCode;
38
+ } finally {
39
+ try { await store?.closeCommands(); }
40
+ finally {
41
+ if (directory) await rm(directory, { recursive: true, force: true });
42
+ for (const [name, handler] of handlers) process.removeListener(name, handler);
43
+ }
44
+ }
45
+ }