@cedarjs/cli 8.0.0-canary.3431 → 8.0.0-canary.3434

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.
@@ -13,7 +13,7 @@ import {
13
13
  PROCESS_META_DIR_NAME
14
14
  } from "@cedarjs/project-config";
15
15
  import { getPackageManager } from "@cedarjs/project-config/packageManager";
16
- import { getConfig, getPaths } from "../../../lib/index.js";
16
+ import { getPaths } from "../../../lib/index.js";
17
17
  import { MONITOR_ADAPTERS, MONITORS, isMonitor } from "./monitors.js";
18
18
  const CONFIG_FILENAME = "deploy.toml";
19
19
  const DOCS_URL = "https://cedarjs.com/docs/deploy/baremetal";
@@ -142,25 +142,8 @@ const API_PROCESS_META_FILES = GENERATED_DATA_DIRS.map(
142
142
  API_PROCESS_META_FILE_NAME
143
143
  ].join("/")
144
144
  );
145
- const API_SERVER_DIST_DIRS = [
146
- "node_modules/@cedarjs/api-server/dist",
147
- "api/node_modules/@cedarjs/api-server/dist"
148
- ].map((dir) => `${CURRENT_RELEASE_SYMLINK_NAME}/${dir}`);
149
- const releaseWritesApiProcessMeta = async (ssh, serverConfig) => {
150
- try {
151
- await ssh.exec(serverConfig.path, "grep", [
152
- "-rqs",
153
- "writeApiProcessMeta",
154
- ...API_SERVER_DIST_DIRS
155
- ]);
156
- return true;
157
- } catch (e) {
158
- if (typeof e === "object" && e !== null && "exitCode" in e && (e.exitCode === 1 || e.exitCode === 2)) {
159
- return false;
160
- }
161
- throw e;
162
- }
163
- };
145
+ class ApiProcessMetaMissingError extends Error {
146
+ }
164
147
  const readApiProcessMeta = async (ssh, serverConfig) => {
165
148
  const [preferredFile, fallbackFile] = API_PROCESS_META_FILES;
166
149
  let contents = "";
@@ -173,8 +156,11 @@ const readApiProcessMeta = async (ssh, serverConfig) => {
173
156
  fallbackFile
174
157
  ]);
175
158
  contents = result.stdout;
176
- } catch {
177
- throw new Error(
159
+ } catch (e) {
160
+ if (typeof e !== "object" || e === null || !("exitCode" in e) || e.exitCode !== 1) {
161
+ throw e;
162
+ }
163
+ throw new ApiProcessMetaMissingError(
178
164
  `The api server hasn't written ${preferredFile} yet. It does that once it's listening.`
179
165
  );
180
166
  }
@@ -217,24 +203,13 @@ const waitForHealthCheck = async ({
217
203
  const deadline = Date.now() + timeoutSeconds * 1e3;
218
204
  let lastFailure = "";
219
205
  let keepTrying = true;
220
- let writesApiProcessMeta;
221
- const apiProcessMeta = async () => {
222
- try {
223
- return await readApiProcessMeta(ssh, serverConfig);
224
- } catch (e) {
225
- writesApiProcessMeta ??= await releaseWritesApiProcessMeta(
226
- ssh,
227
- serverConfig
228
- );
229
- if (writesApiProcessMeta) {
230
- throw e;
231
- }
232
- return { port: getConfig().api.port, host: "" };
233
- }
234
- };
206
+ let apiProcessMetaMissing = false;
235
207
  while (keepTrying) {
236
208
  try {
237
- const url = "url" in target ? target.url : apiServerUrl(await apiProcessMeta(), target.apiPath);
209
+ const url = "url" in target ? target.url : apiServerUrl(
210
+ await readApiProcessMeta(ssh, serverConfig),
211
+ target.apiPath
212
+ );
238
213
  await ssh.exec(serverConfig.path, "curl", [
239
214
  "--fail",
240
215
  "--location",
@@ -248,6 +223,7 @@ const waitForHealthCheck = async ({
248
223
  ]);
249
224
  return;
250
225
  } catch (e) {
226
+ apiProcessMetaMissing = e instanceof ApiProcessMetaMissingError;
251
227
  lastFailure = e instanceof Error ? e.message : String(e);
252
228
  onFailedAttempt?.(lastFailure);
253
229
  }
@@ -260,6 +236,12 @@ const waitForHealthCheck = async ({
260
236
  [
261
237
  `Health check failed: ${describeHealthCheckTarget(target)} did not respond successfully within ${timeoutSeconds} seconds of restarting the ${serverConfig.processNames?.join(", ")} process(es).`,
262
238
  `Last attempt: ${lastFailure}`,
239
+ // TODO: Remove this hint in the next major. By then the releases kept
240
+ // on servers have had plenty of time to all be built with a Cedar
241
+ // version that writes the process meta file
242
+ ...apiProcessMetaMissing ? [
243
+ "Releases built with a Cedar version from before the api server wrote this file never write it. This includes a release you rolled back to from before you upgraded Cedar. Set `healthCheckUrl` in deploy.toml to check such a release."
244
+ ] : [],
263
245
  "",
264
246
  ...nextSteps,
265
247
  `If your app serves its health check somewhere else, set \`healthCheckUrl\` in deploy.toml. Set it to \`false\` to skip the check. See ${DOCS_URL}#health-check`
@@ -979,6 +961,7 @@ const handler = async (yargs) => {
979
961
  }
980
962
  };
981
963
  export {
964
+ ApiProcessMetaMissingError,
982
965
  DEFAULT_SERVER_CONFIG,
983
966
  RELEASE_DIR_PATTERN,
984
967
  apiServerUrl,
@@ -994,7 +977,6 @@ export {
994
977
  manifestAssetFiles,
995
978
  parseConfig,
996
979
  readApiProcessMeta,
997
- releaseWritesApiProcessMeta,
998
980
  rollbackTasks,
999
981
  serverConfigWithDefaults,
1000
982
  throwMissingConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "8.0.0-canary.3431",
3
+ "version": "8.0.0-canary.3434",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,17 +36,17 @@
36
36
  "@babel/preset-typescript": "7.29.7",
37
37
  "@babel/traverse": "7.29.10",
38
38
  "@babel/types": "7.29.8",
39
- "@cedarjs/api-server": "8.0.0-canary.3431",
40
- "@cedarjs/babel-config": "8.0.0-canary.3431",
41
- "@cedarjs/cli-helpers": "8.0.0-canary.3431",
42
- "@cedarjs/internal": "8.0.0-canary.3431",
43
- "@cedarjs/prerender": "8.0.0-canary.3431",
44
- "@cedarjs/project-config": "8.0.0-canary.3431",
45
- "@cedarjs/structure": "8.0.0-canary.3431",
46
- "@cedarjs/telemetry": "8.0.0-canary.3431",
47
- "@cedarjs/utils": "8.0.0-canary.3431",
48
- "@cedarjs/vite": "8.0.0-canary.3431",
49
- "@cedarjs/web-server": "8.0.0-canary.3431",
39
+ "@cedarjs/api-server": "8.0.0-canary.3434",
40
+ "@cedarjs/babel-config": "8.0.0-canary.3434",
41
+ "@cedarjs/cli-helpers": "8.0.0-canary.3434",
42
+ "@cedarjs/internal": "8.0.0-canary.3434",
43
+ "@cedarjs/prerender": "8.0.0-canary.3434",
44
+ "@cedarjs/project-config": "8.0.0-canary.3434",
45
+ "@cedarjs/structure": "8.0.0-canary.3434",
46
+ "@cedarjs/telemetry": "8.0.0-canary.3434",
47
+ "@cedarjs/utils": "8.0.0-canary.3434",
48
+ "@cedarjs/vite": "8.0.0-canary.3434",
49
+ "@cedarjs/web-server": "8.0.0-canary.3434",
50
50
  "@listr2/prompt-adapter-enquirer": "4.4.0",
51
51
  "@opentelemetry/api": "1.9.1",
52
52
  "@opentelemetry/core": "2.12.0",
@@ -94,7 +94,7 @@
94
94
  "yargs": "17.7.3"
95
95
  },
96
96
  "devDependencies": {
97
- "@cedarjs/framework-tools": "8.0.0-canary.3431",
97
+ "@cedarjs/framework-tools": "8.0.0-canary.3434",
98
98
  "@prisma/dmmf": "7.10.0",
99
99
  "@types/archiver": "^7.0.0",
100
100
  "memfs": "4.80.0",