arcadible 1.0.47 → 1.0.49

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.
@@ -12,6 +12,7 @@ import { HttpError } from "../../util/http.js";
12
12
  import { isRetry } from "../../config/retry.js";
13
13
  import { sleep } from "../../util/delay.js";
14
14
  import { isTable } from "../../util/objs.js";
15
+ import { TIMEOUT } from "../../util/request.js";
15
16
  import { channelOf, gameOf, headersOf, isRefused, REFUSED } from "../game.js";
16
17
  import { answerUnread, functionLogsFull, functionLogsRefused, functionLogsSinceInvalid, functionLogsVersionInvalid, gameNotOwned, unableToReach, } from "../../phrase/index.js";
17
18
  // [declare]
@@ -151,6 +152,7 @@ async function pageOf(token, query, last) {
151
152
  try {
152
153
  res = await fetch(query.size ? `${token.url}?${query.toString()}` : token.url, {
153
154
  headers: { authorization: `Bearer ${token.token}` },
155
+ signal: AbortSignal.timeout(TIMEOUT),
154
156
  });
155
157
  }
156
158
  catch (ex) {
@@ -14,7 +14,7 @@ export function initialized() {
14
14
  export function initializedNoStarter() {
15
15
  return [
16
16
  "No starter added: the folder exists.",
17
- `To start from one, run \`${TOOL} init <name>\`.`,
17
+ `To start from one, run \`${TOOL} init <project>\`.`,
18
18
  ];
19
19
  }
20
20
  // [function]
@@ -1,5 +1,5 @@
1
1
  // the game's origin, as Arcadible's router and storage answer it
2
- // (app/src/cloudfront/io-arcadible-router): a path ending in / gets its
2
+ // (app/src/cloudflare/io-arcadible-router): a path ending in / gets its
3
3
  // index.html, a path is found only with its exact letter case, /arcadible/
4
4
  // holds only Arcadible's own files, and each file has the type the release
5
5
  // pipeline gives it. The headers are the build origin's, but nothing is
@@ -53,7 +53,7 @@ function plain(res, status, headers = {}) {
53
53
  }
54
54
  // [function]
55
55
  // what a build may load and reach, as Arcadible's edge sends it
56
- // (app/src/cloudfront/io-arcadible-router): its own origin alone, which
56
+ // (app/src/cloudflare/io-arcadible-router): its own origin alone, which
57
57
  // serves its files, the SDK, and its function, with no frames, and only
58
58
  // `page` framing it; and the names its manifest declares (`[client]`), over
59
59
  // https and wss, as the edge adds them. Locally, the developer's own machine
@@ -38,12 +38,13 @@ export const PLAYER = "x-arcadible-player";
38
38
  export const GUEST = "x-arcadible-guest";
39
39
  // what a request can't bring to a function, as on Arcadible, where the
40
40
  // dispatcher drops each (app/src/cloudflare/io-arcadible-runner-dispatch):
41
- // its ticket, which the code never sees, and the headers Arcadible's own
42
- // parts speak to each other in, a function's secrets among them.
41
+ // its ticket, which the code never sees, a cookie, which a build's origin
42
+ // never keeps, and the headers Arcadible's own parts speak to each other in,
43
+ // a function's secrets among them.
43
44
  export const DROPPED = [
44
45
  "authorization",
46
+ "cookie",
45
47
  "x-arcadible-claim",
46
- "x-arcadible-edge",
47
48
  "x-arcadible-secrets",
48
49
  "x-arcadible-site",
49
50
  ];
@@ -109,6 +110,17 @@ const CORS = {
109
110
  "access-control-max-age": "600",
110
111
  };
111
112
  // [function]
113
+ /**
114
+ * A function's answer's headers, as the game gets them: with what lets
115
+ * another origin read them, and without a cookie it would set, as the
116
+ * dispatcher drops one, since a build's origin never keeps one.
117
+ */
118
+ export function answered(headers) {
119
+ const passed = { ...headers, ...CORS };
120
+ delete passed["set-cookie"];
121
+ return passed;
122
+ }
123
+ // [function]
112
124
  // Arcadible's own answer, marked as the dispatcher marks it: a status, a
113
125
  // code the SDK's `functions.fetch` rejects with, its message, and whether
114
126
  // to try again.
@@ -521,7 +533,7 @@ export async function runner({ dir, handler, hosts = [], main, origin, secrets =
521
533
  path: innerPath(req.url ?? ""),
522
534
  port,
523
535
  }, (answer) => {
524
- res.writeHead(answer.statusCode ?? 502, { ...answer.headers, ...CORS });
536
+ res.writeHead(answer.statusCode ?? 502, answered(answer.headers));
525
537
  answer.pipe(res);
526
538
  });
527
539
  forward.on("error", fail);
@@ -10,6 +10,12 @@ import { client, id } from "../config/product.js";
10
10
  const CLIENT = client;
11
11
  const ID = id;
12
12
  const VERSION = version;
13
+ // how long a request waits on the API, its answer's body included, before
14
+ // it's api_unreachable: the API gives up on the database at 10 seconds, so
15
+ // one that hasn't answered in 30 isn't going to (LIMITS.md, How long things
16
+ // last), and a connection that hangs would otherwise hold the command for
17
+ // minutes.
18
+ export const TIMEOUT = 30_000;
13
19
  // [function]
14
20
  // the body as JSON, or null when it isn't JSON, such as a proxy's error page.
15
21
  function json(resp) {
@@ -59,8 +65,8 @@ function parse(resp) {
59
65
  // [function]
60
66
  // sends a request to a full URL. `headers` are added to the client's own, and
61
67
  // a form is sent as JSON, its fields as text; `{ json }` is sent as the JSON
62
- // it is. A request that gets no response, such as when offline, rejects as
63
- // api_unreachable.
68
+ // it is. A request that gets no response, such as when offline, or none in
69
+ // TIMEOUT, rejects as api_unreachable.
64
70
  function send(method, url, form, headers = {}) {
65
71
  const all = {
66
72
  [`X-${CLIENT}-Client-Id`]: ID,
@@ -73,15 +79,19 @@ function send(method, url, form, headers = {}) {
73
79
  : form instanceof FormData
74
80
  ? JSON.stringify(Object.fromEntries(form))
75
81
  : JSON.stringify(form.json);
82
+ const unreachable = (ex) => {
83
+ throw new ArcError(API_UNREACHABLE, unableToReach(), {
84
+ cause: ex,
85
+ });
86
+ };
76
87
  return fetch(url, {
77
88
  body,
78
89
  headers: all,
79
90
  method,
80
- }).then(parse, (ex) => {
81
- throw new ArcError(API_UNREACHABLE, unableToReach(), {
82
- cause: ex,
83
- });
84
- });
91
+ signal: AbortSignal.timeout(TIMEOUT),
92
+ }).then(
93
+ // a body cut off by the clock is unreachable too; a refusal is the API's
94
+ (resp) => parse(resp).catch((ex) => ex instanceof HttpError ? Promise.reject(ex) : unreachable(ex)), unreachable);
85
95
  }
86
96
  // [function]
87
97
  export function get(url, headers) {
package/dist/util/s3.js CHANGED
@@ -7,6 +7,11 @@ import { ArcError } from "./error.js";
7
7
  import { unableToReach, uploadFailed } from "../phrase/index.js";
8
8
  // [declare]
9
9
  const CHECKSUM = "x-amz-checksum-sha256";
10
+ // how long the upload's connection may sit with nothing sent or answered
11
+ // before it's api_unreachable: idle, not the whole upload, which takes as
12
+ // long as the zip's size and the connection make it (LIMITS.md, How long
13
+ // things last).
14
+ export const IDLE = 60_000;
10
15
  // [function]
11
16
  // whether the upload link signs `header`, which must then be sent.
12
17
  function signs(url, header) {
@@ -30,8 +35,8 @@ function requestOpts(url, { sha256, size }) {
30
35
  }
31
36
  // [function]
32
37
  // puts the file to the upload link, and resolves once S3 accepts it. A
33
- // request that gets no response rejects as api_unreachable; a file that can't
34
- // be read rejects with its own error.
38
+ // request that gets no response, or sits idle for IDLE, rejects as
39
+ // api_unreachable; a file that can't be read rejects with its own error.
35
40
  // `https.request` is called through the module, as it is when the request is
36
41
  // made, so the tests' sandbox can replace it (test/support/preload.js).
37
42
  export function upload(url, { path, sha256, size }, onProgress) {
@@ -46,6 +51,9 @@ export function upload(url, { path, sha256, size }, onProgress) {
46
51
  reject(new ArcError(UPLOAD_FAILED, uploadFailed(status), { status }));
47
52
  });
48
53
  let readError = null;
54
+ req.setTimeout(IDLE, () => {
55
+ req.destroy(new DOMException(`No progress in ${IDLE / 1000} seconds.`, "TimeoutError"));
56
+ });
49
57
  req.on("error", (ex) => {
50
58
  reject(readError ??
51
59
  new ArcError(API_UNREACHABLE, unableToReach(), {
@@ -16,7 +16,7 @@
16
16
  "esbuild": "0.28.2",
17
17
  "fast-json-stable-stringify": "2.1.0",
18
18
  "fs-extra": "11.4.1",
19
- "image-size": "2.1.0",
19
+ "image-size": "2.2.0",
20
20
  "marked": "17.0.6",
21
21
  "mime-types": "3.0.2",
22
22
  "mp4box": "2.6.0",
@@ -26,14 +26,14 @@
26
26
  "qrcode-terminal": "0.12.0",
27
27
  "range-parser": "1.3.0",
28
28
  "semver": "7.8.6",
29
- "ws": "8.23.0",
29
+ "ws": "8.23.1",
30
30
  "yargs": "17.7.3",
31
31
  "zod": "4.6.7"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@eslint/js": "10.0.1",
35
35
  "@types/node": "25.9.12",
36
- "eslint": "10.15.0",
36
+ "eslint": "10.16.0",
37
37
  "typescript": "5.9.3",
38
38
  "typescript-eslint": "8.74.0"
39
39
  },
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "license": "Apache-2.0",
44
44
  "name": "arcadible",
45
- "version": "1.0.47"
45
+ "version": "1.0.49"
46
46
  },
47
47
  "node_modules/@cacheable/memory": {
48
48
  "dependencies": {
@@ -536,10 +536,10 @@
536
536
  "engines": {
537
537
  "node": "^20.19.0 || ^22.13.0 || >=24"
538
538
  },
539
- "integrity": "sha512-WrTH7nioI9QPY4NZGnsywmecswJdgeq4BCM76qok9VgjTO29ZgUzUvcuJLVPYVQM4uDbaPBU0M33R9DIxI8X3w==",
539
+ "integrity": "sha512-Ix1tmZjA7/OmE7ROAfORe83hVnqlDzLpZVHFjHQt5mvLm1U03qMexpaxKqFIL362QV32SoPaZqmKQr3tdqFY2w==",
540
540
  "license": "Apache-2.0",
541
- "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.6.tgz",
542
- "version": "0.23.6"
541
+ "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.7.tgz",
542
+ "version": "0.23.7"
543
543
  },
544
544
  "node_modules/@eslint/config-helpers": {
545
545
  "dependencies": {
@@ -1378,7 +1378,7 @@
1378
1378
  "dependencies": {
1379
1379
  "@eslint-community/eslint-utils": "^4.8.0",
1380
1380
  "@eslint-community/regexpp": "^4.12.2",
1381
- "@eslint/config-array": "^0.23.6",
1381
+ "@eslint/config-array": "^0.23.7",
1382
1382
  "@eslint/config-helpers": "^0.7.0",
1383
1383
  "@eslint/core": "^1.2.1",
1384
1384
  "@eslint/plugin-kit": "^0.7.3",
@@ -1414,7 +1414,7 @@
1414
1414
  "funding": {
1415
1415
  "url": "https://eslint.org/donate"
1416
1416
  },
1417
- "integrity": "sha512-+5Wg4p+ze3sG1WErYgUO/3H1IQIfFBymVUA0Fo/XTeBOLS6UQIUekpSJ8sdRkn7O7wjh84b55w/roqavH2aScg==",
1417
+ "integrity": "sha512-Xu3PRLG/wCaZWZ20gkExUcNqL2mWWsXTR+Lln3Sof4Y9WuA678fH9hrlQ8B6UNwbTnsKdDdBYOd2jxtycXVTGQ==",
1418
1418
  "license": "MIT",
1419
1419
  "peerDependencies": {
1420
1420
  "jiti": "*"
@@ -1424,8 +1424,8 @@
1424
1424
  "optional": true
1425
1425
  }
1426
1426
  },
1427
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.15.0.tgz",
1428
- "version": "10.15.0",
1427
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.16.0.tgz",
1428
+ "version": "10.16.0",
1429
1429
  "workspaces": [
1430
1430
  "packages/*"
1431
1431
  ]
@@ -1687,12 +1687,12 @@
1687
1687
  "image-size": "bin/image-size.js"
1688
1688
  },
1689
1689
  "engines": {
1690
- "node": ">=18"
1690
+ "node": ">=22"
1691
1691
  },
1692
- "integrity": "sha512-6Dbisa46RsgeAh3TMSFL2i8+uIFG+/LRmz6Q2oscSJJvXo1sOw3EgNO4M8jPl1P+gR1atJLDPrpclX4IHz63sA==",
1692
+ "integrity": "sha512-93QTtmEv0UD26RTJfmxQvWzhlauWO1TizNPjCumqzlACXYmI7TlwRWWT2+M4at7kZwnj+WkMOW9XKI76eX0dWw==",
1693
1693
  "license": "MIT",
1694
- "resolved": "https://registry.npmjs.org/image-size/-/image-size-2.1.0.tgz",
1695
- "version": "2.1.0"
1694
+ "resolved": "https://registry.npmjs.org/image-size/-/image-size-2.2.0.tgz",
1695
+ "version": "2.2.0"
1696
1696
  },
1697
1697
  "node_modules/imurmurhash": {
1698
1698
  "dev": true,
@@ -2341,7 +2341,7 @@
2341
2341
  "engines": {
2342
2342
  "node": ">=10.0.0"
2343
2343
  },
2344
- "integrity": "sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==",
2344
+ "integrity": "sha512-1rzWDSN0NOi3tpwgHsQExjWRoKUGtjCkJ2gZRaaRtzhYLboMytOI9pj9PU7yCgY37auqdd4OyLofZDbkeuZmPA==",
2345
2345
  "license": "MIT",
2346
2346
  "peerDependencies": {
2347
2347
  "bufferutil": "^4.0.1",
@@ -2355,8 +2355,8 @@
2355
2355
  "optional": true
2356
2356
  }
2357
2357
  },
2358
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.23.0.tgz",
2359
- "version": "8.23.0"
2358
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.23.1.tgz",
2359
+ "version": "8.23.1"
2360
2360
  },
2361
2361
  "node_modules/wsl-utils": {
2362
2362
  "dependencies": {
@@ -2433,5 +2433,5 @@
2433
2433
  }
2434
2434
  },
2435
2435
  "requires": true,
2436
- "version": "1.0.47"
2436
+ "version": "1.0.49"
2437
2437
  }
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "esbuild": "0.28.2",
14
14
  "fast-json-stable-stringify": "2.1.0",
15
15
  "fs-extra": "11.4.1",
16
- "image-size": "2.1.0",
16
+ "image-size": "2.2.0",
17
17
  "marked": "17.0.6",
18
18
  "mime-types": "3.0.2",
19
19
  "mp4box": "2.6.0",
@@ -23,7 +23,7 @@
23
23
  "qrcode-terminal": "0.12.0",
24
24
  "range-parser": "1.3.0",
25
25
  "semver": "7.8.6",
26
- "ws": "8.23.0",
26
+ "ws": "8.23.1",
27
27
  "yargs": "17.7.3",
28
28
  "zod": "4.6.7"
29
29
  },
@@ -31,7 +31,7 @@
31
31
  "devDependencies": {
32
32
  "@eslint/js": "10.0.1",
33
33
  "@types/node": "25.9.12",
34
- "eslint": "10.15.0",
34
+ "eslint": "10.16.0",
35
35
  "typescript": "5.9.3",
36
36
  "typescript-eslint": "8.74.0"
37
37
  },
@@ -45,6 +45,7 @@
45
45
  "assets",
46
46
  "bin",
47
47
  "dist",
48
+ "!dist/.source.sha256",
48
49
  "npm-shrinkwrap.json",
49
50
  "product.json"
50
51
  ],
@@ -60,11 +61,11 @@
60
61
  "license": "Apache-2.0",
61
62
  "name": "arcadible",
62
63
  "scripts": {
63
- "build": "tsc",
64
+ "build": "tsc && node ../../../src/cloudflare/io-arcadible-runner-dispatch/built.mjs .",
64
65
  "lint": "eslint -c eslint.config.mjs src",
65
66
  "prepack": "rm -rf dist && npm run build",
66
67
  "test": "tsc && npm run lint && node --test \"test/**/*.test.js\" \"test/**/*.test.mjs\""
67
68
  },
68
69
  "type": "module",
69
- "version": "1.0.47"
70
+ "version": "1.0.49"
70
71
  }