@pipelex/sdk 0.23.0 → 0.24.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/dist/artifacts.d.ts +4 -1
- package/dist/artifacts.js +6 -1
- package/dist/artifacts.js.map +1 -1
- package/dist/client.d.ts +6 -2
- package/dist/client.js +15 -4
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +30 -5
- package/dist/errors.js +9 -5
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/runs.d.ts +10 -1
- package/dist/runs.js +17 -1
- package/dist/runs.js.map +1 -1
- package/dist/timers.d.ts +11 -0
- package/dist/timers.js +14 -0
- package/dist/timers.js.map +1 -0
- package/dist/upload-grant.d.ts +38 -15
- package/dist/upload-grant.js +200 -67
- package/dist/upload-grant.js.map +1 -1
- package/dist/upload.js +9 -2
- package/dist/upload.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/architecture.md +4 -3
- package/docs/artifact-download.md +1 -1
- package/docs/input-preparation.md +14 -8
- package/package.json +2 -2
package/dist/runs.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RunFailedError, RunTimeoutError } from "./errors.js";
|
|
2
|
+
import { MAX_TIMER_DELAY_MS } from "./timers.js";
|
|
2
3
|
const TERMINAL_RUN_STATUSES = new Set([
|
|
3
4
|
"COMPLETED",
|
|
4
5
|
"FAILED",
|
|
@@ -17,6 +18,18 @@ export function isSuccessRunStatus(status) {
|
|
|
17
18
|
// ── Poll loop ───────────────────────────────────────────────────────
|
|
18
19
|
export const DEFAULT_POLL_INTERVAL_MS = 2_000;
|
|
19
20
|
export const DEFAULT_WAIT_TIMEOUT_MS = 1_200_000; // 20 min — matches the runner's blocking execute ceiling.
|
|
21
|
+
/**
|
|
22
|
+
* Refuse wait options no poll loop can honour. A NaN would reach the sleep's timer as a
|
|
23
|
+
* 1 ms delay and poll in a tight loop. `startAndWaitForResult` calls this before it starts
|
|
24
|
+
* the run, so a bad option never leaves a started run the caller holds no id for.
|
|
25
|
+
*/
|
|
26
|
+
export function assertWaitOptions(options = {}) {
|
|
27
|
+
const { intervalMs, timeoutMs } = options;
|
|
28
|
+
if (Number.isNaN(intervalMs) || Number.isNaN(timeoutMs)) {
|
|
29
|
+
throw new RangeError(`"intervalMs" and "timeoutMs" must be numbers, got ${String(intervalMs)} and ` +
|
|
30
|
+
`${String(timeoutMs)}.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
20
33
|
/**
|
|
21
34
|
* Poll a single-shot result lookup (`fetchOnce`) until the run reaches a
|
|
22
35
|
* terminal state. Returns the artifacts on `COMPLETED`, throws `RunFailedError`
|
|
@@ -27,6 +40,7 @@ export const DEFAULT_WAIT_TIMEOUT_MS = 1_200_000; // 20 min — matches the runn
|
|
|
27
40
|
* delegates here, so the behavior can never drift.
|
|
28
41
|
*/
|
|
29
42
|
export async function pollUntilResult(fetchOnce, runId, options = {}) {
|
|
43
|
+
assertWaitOptions(options);
|
|
30
44
|
const intervalMs = options.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
31
45
|
const timeoutMs = options.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
|
|
32
46
|
const startedAt = Date.now();
|
|
@@ -75,10 +89,12 @@ function sleep(ms, signal) {
|
|
|
75
89
|
clearTimeout(timer);
|
|
76
90
|
reject(abortError(signal));
|
|
77
91
|
};
|
|
92
|
+
// Clamped, since a longer delay overflows the timer and would fire at once: a sleep
|
|
93
|
+
// past the cap ends at the cap, and the loop simply polls again.
|
|
78
94
|
const timer = setTimeout(() => {
|
|
79
95
|
signal?.removeEventListener("abort", onAbort);
|
|
80
96
|
resolve();
|
|
81
|
-
}, ms);
|
|
97
|
+
}, Math.min(ms, MAX_TIMER_DELAY_MS));
|
|
82
98
|
if (signal) {
|
|
83
99
|
if (signal.aborted) {
|
|
84
100
|
clearTimeout(timer);
|
package/dist/runs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAwCjD,MAAM,qBAAqB,GAA2B,IAAI,GAAG,CAAY;IACvE,WAAW;IACX,QAAQ;IACR,WAAW;IACX,YAAY;IACZ,WAAW;CACZ,CAAC,CAAC;AAEH,6EAA6E;AAC7E,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,OAAO,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,OAAO,MAAM,KAAK,WAAW,CAAC;AAChC,CAAC;AAiPD,uEAAuE;AAEvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC,CAAC,0DAA0D;AAQ5G;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAgC,EAAE;IAClE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC1C,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QACxD,MAAM,IAAI,UAAU,CAClB,qDAAqD,MAAM,CAAC,UAAU,CAAC,OAAO;YAC5E,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAC1B,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KA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,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC3B,OAAO;YACT,CAAC;YACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/timers.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bound every caller-supplied delay is checked against before it reaches a timer.
|
|
3
|
+
* This module imports nothing, so the browser-safe `@pipelex/sdk/upload` entry can use it.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The longest delay `setTimeout` honours, in milliseconds. A longer one overflows, and
|
|
7
|
+
* Node and browsers alike then fire the timer almost at once.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MAX_TIMER_DELAY_MS = 2147483647;
|
|
10
|
+
/** Whether `value` is a delay a timer honours: a positive, finite number no larger than the cap. */
|
|
11
|
+
export declare function isTimerDelay(value: number): boolean;
|
package/dist/timers.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bound every caller-supplied delay is checked against before it reaches a timer.
|
|
3
|
+
* This module imports nothing, so the browser-safe `@pipelex/sdk/upload` entry can use it.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The longest delay `setTimeout` honours, in milliseconds. A longer one overflows, and
|
|
7
|
+
* Node and browsers alike then fire the timer almost at once.
|
|
8
|
+
*/
|
|
9
|
+
export const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
10
|
+
/** Whether `value` is a delay a timer honours: a positive, finite number no larger than the cap. */
|
|
11
|
+
export function isTimerDelay(value) {
|
|
12
|
+
return Number.isFinite(value) && value > 0 && value <= MAX_TIMER_DELAY_MS;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=timers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timers.js","sourceRoot":"","sources":["../src/timers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAEhD,oGAAoG;AACpG,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,kBAAkB,CAAC;AAC5E,CAAC"}
|
package/dist/upload-grant.d.ts
CHANGED
|
@@ -7,21 +7,31 @@
|
|
|
7
7
|
*
|
|
8
8
|
* **This module is the browser-safe entry, `@pipelex/sdk/upload`.** Its runtime
|
|
9
9
|
* import graph must never reach a Node builtin, `undici` or the client: a page
|
|
10
|
-
* bundles it as is, with nothing marked external. It imports the error classes
|
|
11
|
-
*
|
|
12
|
-
* browser with esbuild to hold it
|
|
10
|
+
* bundles it as is, with nothing marked external. It imports the error classes,
|
|
11
|
+
* the timer bound in `timers.ts` and the wire types only, and
|
|
12
|
+
* `tests/upload-grant.test.ts` bundles it for the browser with esbuild to hold it
|
|
13
|
+
* to that.
|
|
13
14
|
*/
|
|
14
15
|
import type { UploadGrant } from "./product-models.js";
|
|
15
16
|
export type { UploadGrant, UploadGrantInput } from "./product-models.js";
|
|
16
17
|
export { InputPreparationError, RejectedAssetError, UploadTransportError } from "./errors.js";
|
|
17
|
-
export type { RejectedAssetCode } from "./errors.js";
|
|
18
|
+
export type { RejectedAssetCode, UploadTransportCode } from "./errors.js";
|
|
18
19
|
/** Per-call options for {@link uploadWithGrant}. */
|
|
19
20
|
export interface UploadWithGrantOptions {
|
|
20
21
|
/**
|
|
21
22
|
* Cancels the upload. A caller's abort propagates as the signal's own reason,
|
|
22
|
-
* never wrapped, so it stays distinguishable from a failure.
|
|
23
|
+
* never wrapped, so it stays distinguishable from a failure. It ends the upload
|
|
24
|
+
* whenever it fires, so it can shorten the time limit but never lengthen it.
|
|
23
25
|
*/
|
|
24
26
|
signal?: AbortSignal;
|
|
27
|
+
/**
|
|
28
|
+
* The time limit on the whole exchange with storage, in milliseconds, replacing
|
|
29
|
+
* the default of 60 s plus 1 s for every started 128 KiB of the file — about
|
|
30
|
+
* 1 Mbit/s, so 460 s for a 50 MiB file. Pass a longer one for a slower link. It
|
|
31
|
+
* must be a positive number no larger than 2147483647, the longest delay a timer
|
|
32
|
+
* honours.
|
|
33
|
+
*/
|
|
34
|
+
timeoutMs?: number;
|
|
25
35
|
}
|
|
26
36
|
/** What a successful {@link uploadWithGrant} stored. */
|
|
27
37
|
export interface GrantedUpload {
|
|
@@ -44,17 +54,30 @@ export interface GrantedUpload {
|
|
|
44
54
|
* (`unsigned_header`), or when the grant has expired (`grant_expired`); any other
|
|
45
55
|
* `4xx` (`store_refused`). Each asks for a new grant, or for the file the grant
|
|
46
56
|
* was requested for.
|
|
47
|
-
* - `UploadTransportError` (`status` is storage's when it answered
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
57
|
+
* - `UploadTransportError` (`status` is storage's when it answered, `code` says
|
|
58
|
+
* which) — the time limit running out (`timeout`), storage unreachable
|
|
59
|
+
* (`unreachable`), a `5xx` (`server_error`), storage timing out on the body
|
|
60
|
+
* (`storage_timeout`, a `400 RequestTimeout`, which wrote nothing), another upload
|
|
61
|
+
* with the same grant still in progress (`conflict`, a `409
|
|
62
|
+
* ConditionalRequestConflict`), or a redirect, which is refused rather than
|
|
63
|
+
* followed (`redirected`). In a browser a refused cross-origin request looks like
|
|
64
|
+
* an unreachable host, so the message names that too. A grant whose `url` is not
|
|
65
|
+
* an absolute `http(s)` URL free of user info is refused the same way, before
|
|
66
|
+
* anything is sent (`invalid_grant_url`).
|
|
67
|
+
*
|
|
68
|
+
* The whole exchange runs under a time limit: `timeoutMs` when given, else 60 s plus
|
|
69
|
+
* 1 s for every started 128 KiB of the file. A caller's `signal` can end it sooner,
|
|
70
|
+
* and its abort propagates as the signal's own reason, unwrapped, even when the time
|
|
71
|
+
* limit ran out too. Only the first 16 KiB of storage's error body are read, and when
|
|
72
|
+
* the limit runs out while that body is still arriving, storage has already answered:
|
|
73
|
+
* the call settles as that answer, classified from its status and whatever part of the
|
|
74
|
+
* body arrived.
|
|
53
75
|
*
|
|
54
|
-
* A `5xx
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
76
|
+
* A timeout, a `5xx`, a conflict and a connection lost after the file went out leave
|
|
77
|
+
* it unknown whether the object was written: retrying with the same grant before it
|
|
78
|
+
* expires either stores it or answers the `412` of a used grant, and then the
|
|
79
|
+
* grant's `uri` already names the file. The grant is a bearer capability: nothing
|
|
80
|
+
* here logs it, and no error this throws carries its URL, storage's error body or a
|
|
58
81
|
* runtime error that could hold either.
|
|
59
82
|
*/
|
|
60
83
|
export declare function uploadWithGrant(grant: UploadGrant, file: Blob, options?: UploadWithGrantOptions): Promise<GrantedUpload>;
|
package/dist/upload-grant.js
CHANGED
|
@@ -7,13 +7,29 @@
|
|
|
7
7
|
*
|
|
8
8
|
* **This module is the browser-safe entry, `@pipelex/sdk/upload`.** Its runtime
|
|
9
9
|
* import graph must never reach a Node builtin, `undici` or the client: a page
|
|
10
|
-
* bundles it as is, with nothing marked external. It imports the error classes
|
|
11
|
-
*
|
|
12
|
-
* browser with esbuild to hold it
|
|
10
|
+
* bundles it as is, with nothing marked external. It imports the error classes,
|
|
11
|
+
* the timer bound in `timers.ts` and the wire types only, and
|
|
12
|
+
* `tests/upload-grant.test.ts` bundles it for the browser with esbuild to hold it
|
|
13
|
+
* to that.
|
|
13
14
|
*/
|
|
14
|
-
import { RejectedAssetError, UploadTransportError } from "./errors.js";
|
|
15
|
+
import { InputPreparationError, RejectedAssetError, UploadTransportError } from "./errors.js";
|
|
16
|
+
import { MAX_TIMER_DELAY_MS, isTimerDelay } from "./timers.js";
|
|
15
17
|
// The classes `uploadWithGrant` raises, so a page can branch on them without the main entry.
|
|
16
18
|
export { InputPreparationError, RejectedAssetError, UploadTransportError } from "./errors.js";
|
|
19
|
+
/**
|
|
20
|
+
* The default time limit on the `PUT`: a minute to open the exchange and hear back,
|
|
21
|
+
* plus a second for every started 128 KiB of the file, about 1 Mbit/s — 460 s at the
|
|
22
|
+
* 50 MiB cap. The grant's expiry bounds nothing here: storage checks the signature
|
|
23
|
+
* when the request starts, not when it ends.
|
|
24
|
+
*/
|
|
25
|
+
const DEFAULT_TIMEOUT_BASE_MS = 60_000;
|
|
26
|
+
const DEFAULT_TIMEOUT_BYTES_PER_SECOND = 128 * 1024;
|
|
27
|
+
/**
|
|
28
|
+
* How much of storage's error body is read. S3 writes `<Code>` and `<Message>` first,
|
|
29
|
+
* and the longest document this meets, a signature mismatch echoing the canonical
|
|
30
|
+
* request, runs to a few kilobytes after them.
|
|
31
|
+
*/
|
|
32
|
+
const ERROR_BODY_MAX_BYTES = 16 * 1024;
|
|
17
33
|
/**
|
|
18
34
|
* `PUT` a file to storage with an upload grant, and return the reference it now
|
|
19
35
|
* carries. The file goes as the raw body with the grant's signed headers
|
|
@@ -30,85 +46,202 @@ export { InputPreparationError, RejectedAssetError, UploadTransportError } from
|
|
|
30
46
|
* (`unsigned_header`), or when the grant has expired (`grant_expired`); any other
|
|
31
47
|
* `4xx` (`store_refused`). Each asks for a new grant, or for the file the grant
|
|
32
48
|
* was requested for.
|
|
33
|
-
* - `UploadTransportError` (`status` is storage's when it answered
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
49
|
+
* - `UploadTransportError` (`status` is storage's when it answered, `code` says
|
|
50
|
+
* which) — the time limit running out (`timeout`), storage unreachable
|
|
51
|
+
* (`unreachable`), a `5xx` (`server_error`), storage timing out on the body
|
|
52
|
+
* (`storage_timeout`, a `400 RequestTimeout`, which wrote nothing), another upload
|
|
53
|
+
* with the same grant still in progress (`conflict`, a `409
|
|
54
|
+
* ConditionalRequestConflict`), or a redirect, which is refused rather than
|
|
55
|
+
* followed (`redirected`). In a browser a refused cross-origin request looks like
|
|
56
|
+
* an unreachable host, so the message names that too. A grant whose `url` is not
|
|
57
|
+
* an absolute `http(s)` URL free of user info is refused the same way, before
|
|
58
|
+
* anything is sent (`invalid_grant_url`).
|
|
59
|
+
*
|
|
60
|
+
* The whole exchange runs under a time limit: `timeoutMs` when given, else 60 s plus
|
|
61
|
+
* 1 s for every started 128 KiB of the file. A caller's `signal` can end it sooner,
|
|
62
|
+
* and its abort propagates as the signal's own reason, unwrapped, even when the time
|
|
63
|
+
* limit ran out too. Only the first 16 KiB of storage's error body are read, and when
|
|
64
|
+
* the limit runs out while that body is still arriving, storage has already answered:
|
|
65
|
+
* the call settles as that answer, classified from its status and whatever part of the
|
|
66
|
+
* body arrived.
|
|
39
67
|
*
|
|
40
|
-
* A `5xx
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
68
|
+
* A timeout, a `5xx`, a conflict and a connection lost after the file went out leave
|
|
69
|
+
* it unknown whether the object was written: retrying with the same grant before it
|
|
70
|
+
* expires either stores it or answers the `412` of a used grant, and then the
|
|
71
|
+
* grant's `uri` already names the file. The grant is a bearer capability: nothing
|
|
72
|
+
* here logs it, and no error this throws carries its URL, storage's error body or a
|
|
44
73
|
* runtime error that could hold either.
|
|
45
74
|
*/
|
|
46
75
|
export async function uploadWithGrant(grant, file, options = {}) {
|
|
47
76
|
const label = fileLabel(grant, file);
|
|
48
|
-
const { signal } = options;
|
|
49
|
-
// A caller's abort wins over a grant this would refuse, as it does over a
|
|
77
|
+
const { signal, timeoutMs } = options;
|
|
78
|
+
// A caller's abort wins over a grant or an option this would refuse, as it does over a
|
|
79
|
+
// failed request.
|
|
50
80
|
if (signal?.aborted)
|
|
51
81
|
throw signal.reason;
|
|
82
|
+
if (timeoutMs !== undefined)
|
|
83
|
+
requireTimeout(timeoutMs);
|
|
84
|
+
const limitMs = timeoutMs ?? defaultTimeoutMs(file.size);
|
|
52
85
|
const target = storageTarget(grant, label);
|
|
53
|
-
|
|
86
|
+
// The call's own controller carries both ways the exchange can be cut short: the
|
|
87
|
+
// caller's signal, forwarded into it, and the time limit, which also covers reading
|
|
88
|
+
// storage's error body.
|
|
89
|
+
const controller = new AbortController();
|
|
90
|
+
let timedOut = false;
|
|
91
|
+
const timer = setTimeout(() => {
|
|
92
|
+
timedOut = true;
|
|
93
|
+
controller.abort(new DOMException("The upload timed out.", "TimeoutError"));
|
|
94
|
+
}, limitMs);
|
|
95
|
+
const onCallerAbort = () => controller.abort(signal?.reason);
|
|
96
|
+
signal?.addEventListener("abort", onCallerAbort, { once: true });
|
|
54
97
|
try {
|
|
55
|
-
response
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
98
|
+
let response;
|
|
99
|
+
try {
|
|
100
|
+
response = await fetch(grant.url, {
|
|
101
|
+
method: "PUT",
|
|
102
|
+
headers: grant.headers,
|
|
103
|
+
body: file,
|
|
104
|
+
// A presigned URL signs its host, so a redirect could never succeed; refusing
|
|
105
|
+
// it keeps the file from being sent anywhere the grant did not name.
|
|
106
|
+
redirect: "manual",
|
|
107
|
+
signal: controller.signal,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
// The signals' outcome, not the runtime's error: some runtimes reject with a generic
|
|
112
|
+
// AbortError instead of the reason. A caller's abort wins over the time limit, since
|
|
113
|
+
// it is the one the caller can see and act on.
|
|
114
|
+
if (signal?.aborted)
|
|
115
|
+
throw signal.reason;
|
|
116
|
+
if (timedOut)
|
|
117
|
+
throw timeoutError(label, limitMs, grant);
|
|
118
|
+
// Neither the runtime's message nor the error itself is kept: either can carry the
|
|
119
|
+
// request URL, and with it the grant's credential (Bun puts it on the error's `path`).
|
|
120
|
+
throw new UploadTransportError(`Upload of "${label}" could not reach storage at ${target.origin} ` +
|
|
121
|
+
`(${describeNetworkFailure(error)}). In a browser, a refused cross-origin request ` +
|
|
122
|
+
"looks the same: check that the page may connect to the storage origin (its CSP " +
|
|
123
|
+
"connect-src). If the connection failed after the file went out, storage may have " +
|
|
124
|
+
`stored it anyway. ${sameGrantRetry(grant)}`, { code: "unreachable" });
|
|
125
|
+
}
|
|
126
|
+
// A body is cancelled, never awaited: a stream's cancel can outlive any time limit.
|
|
127
|
+
if (response.status >= 200 && response.status < 300) {
|
|
128
|
+
void response.body?.cancel().catch(() => undefined);
|
|
129
|
+
return { uri: grant.uri };
|
|
130
|
+
}
|
|
131
|
+
// A browser reports a refused redirect as an opaque response with status 0.
|
|
132
|
+
if (response.type === "opaqueredirect" || (response.status >= 300 && response.status < 400)) {
|
|
133
|
+
void response.body?.cancel().catch(() => undefined);
|
|
134
|
+
throw new UploadTransportError(`Upload of "${label}" was redirected by storage, and the redirect was refused: a ` +
|
|
135
|
+
"presigned upload is valid only at the URL it was signed for.",
|
|
136
|
+
// A refused redirect in a browser is opaque, with status 0: no status reached us.
|
|
137
|
+
{ status: response.status || undefined, code: "redirected" });
|
|
138
|
+
}
|
|
139
|
+
// Only the error's code and message are kept, never the body: S3 echoes the
|
|
140
|
+
// canonical request on a signature mismatch, and with it the grant's credential.
|
|
141
|
+
const body = await readErrorPrefix(response, ERROR_BODY_MAX_BYTES, controller.signal);
|
|
142
|
+
// A caller's abort while the body streams stays the caller's, unwrapped. The time limit
|
|
143
|
+
// running out then is no timeout: storage has answered, and its status says what
|
|
144
|
+
// happened, read with whatever part of the body arrived.
|
|
68
145
|
if (signal?.aborted)
|
|
69
146
|
throw signal.reason;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
`
|
|
74
|
-
|
|
75
|
-
|
|
147
|
+
const refusal = parseStorageError(body);
|
|
148
|
+
const status = response.status;
|
|
149
|
+
if (status === 400 && refusal.code === "RequestTimeout") {
|
|
150
|
+
throw new UploadTransportError(`Upload of "${label}" timed out at storage (${describeStatus(response, refusal)}): ` +
|
|
151
|
+
"storage stopped waiting for the file's bytes and wrote nothing. Retry with the same " +
|
|
152
|
+
`grant before it expires at ${grant.expires_at}, or with a new one.`, { status, code: "storage_timeout" });
|
|
153
|
+
}
|
|
154
|
+
// S3 answers this when two create-only PUTs for one key overlap, and documents it as
|
|
155
|
+
// retryable: it says nothing about this file, so it is no refusal of it.
|
|
156
|
+
if (status === 409 && refusal.code === "ConditionalRequestConflict") {
|
|
157
|
+
throw new UploadTransportError(`Upload of "${label}" met another upload with the same grant still in progress at ` +
|
|
158
|
+
`storage (${describeStatus(response, refusal)}), so whether the file was stored is ` +
|
|
159
|
+
`unknown. Send a grant once at a time. ${sameGrantRetry(grant)}`, { status, code: "conflict" });
|
|
160
|
+
}
|
|
161
|
+
if (status >= 400 && status < 500) {
|
|
162
|
+
const { code, advice } = classifyRefusal(status, refusal, grant);
|
|
163
|
+
throw new RejectedAssetError(`Storage refused the upload of "${label}" (${describeStatus(response, refusal)}): ${advice}`, label, status, { code });
|
|
164
|
+
}
|
|
165
|
+
throw new UploadTransportError(`Upload of "${label}" failed at storage (${describeStatus(response, refusal)})` +
|
|
166
|
+
(refusal.message ? `: ${withoutFinalPeriod(refusal.message)}` : "") +
|
|
167
|
+
`. Whether the file was stored is unknown. ${sameGrantRetry(grant)}`, { status, code: status >= 500 ? "server_error" : "unexpected" });
|
|
76
168
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
169
|
+
finally {
|
|
170
|
+
clearTimeout(timer);
|
|
171
|
+
signal?.removeEventListener("abort", onCallerAbort);
|
|
80
172
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
173
|
+
}
|
|
174
|
+
/** The default time limit for a file of `size` bytes, capped at what a timer honours. */
|
|
175
|
+
function defaultTimeoutMs(size) {
|
|
176
|
+
const seconds = Math.ceil(size / DEFAULT_TIMEOUT_BYTES_PER_SECOND);
|
|
177
|
+
return Math.min(DEFAULT_TIMEOUT_BASE_MS + seconds * 1_000, MAX_TIMER_DELAY_MS);
|
|
178
|
+
}
|
|
179
|
+
/** A caller's `timeoutMs`, refused before anything is sent when no timer could honour it. */
|
|
180
|
+
function requireTimeout(timeoutMs) {
|
|
181
|
+
if (!isTimerDelay(timeoutMs)) {
|
|
182
|
+
throw new InputPreparationError(`"timeoutMs" must be a positive number no larger than ${MAX_TIMER_DELAY_MS}, got ` +
|
|
183
|
+
`${String(timeoutMs)}.`);
|
|
88
184
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
185
|
+
}
|
|
186
|
+
function timeoutError(label, limitMs, grant) {
|
|
187
|
+
return new UploadTransportError(`Upload of "${label}" did not finish within the ${formatSeconds(limitMs)} s allowed, so ` +
|
|
188
|
+
"whether storage stored the file is unknown. On a slow link, pass a longer timeoutMs. " +
|
|
189
|
+
sameGrantRetry(grant), { code: "timeout" });
|
|
190
|
+
}
|
|
191
|
+
/** What to do when the upload may have been stored: the grant itself tells, on a retry. */
|
|
192
|
+
function sameGrantRetry(grant) {
|
|
193
|
+
return (`Retrying with the same grant before it expires at ${grant.expires_at} either stores ` +
|
|
194
|
+
"the file or reports the grant as used, and then the grant's uri already names the file.");
|
|
195
|
+
}
|
|
196
|
+
function formatSeconds(ms) {
|
|
197
|
+
return String(Number((ms / 1_000).toFixed(3)));
|
|
198
|
+
}
|
|
199
|
+
/** A message whose own final period would double the one the sentence adds after it. */
|
|
200
|
+
function withoutFinalPeriod(message) {
|
|
201
|
+
return message.replace(/\.\s*$/, "");
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The first `maxBytes` of storage's error body as text: whatever arrived before the body
|
|
205
|
+
* ended, failed, reached the cap or was cut short by `abort`, since even a partial body
|
|
206
|
+
* may carry S3's code. The rest is cancelled unread, and the cancellation is never
|
|
207
|
+
* awaited, since a stream's cancel can outlive any time limit.
|
|
208
|
+
*/
|
|
209
|
+
async function readErrorPrefix(response, maxBytes, abort) {
|
|
210
|
+
if (response.body === null)
|
|
96
211
|
return "";
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
212
|
+
const reader = response.body.getReader();
|
|
213
|
+
// Cancelled explicitly on abort, on top of the request's own abort, so a stalled body
|
|
214
|
+
// never holds the read past the time limit: a cancel ends a pending read at once.
|
|
215
|
+
const cancel = () => {
|
|
216
|
+
void reader.cancel().catch(() => undefined);
|
|
217
|
+
};
|
|
218
|
+
if (abort.aborted) {
|
|
219
|
+
cancel();
|
|
220
|
+
return "";
|
|
221
|
+
}
|
|
222
|
+
abort.addEventListener("abort", cancel, { once: true });
|
|
223
|
+
const decoder = new TextDecoder();
|
|
224
|
+
let text = "";
|
|
225
|
+
let received = 0;
|
|
226
|
+
try {
|
|
227
|
+
while (received < maxBytes) {
|
|
228
|
+
const chunk = await reader.read();
|
|
229
|
+
if (chunk.done)
|
|
230
|
+
break;
|
|
231
|
+
const bytes = chunk.value.subarray(0, maxBytes - received);
|
|
232
|
+
received += bytes.byteLength;
|
|
233
|
+
text += decoder.decode(bytes, { stream: true });
|
|
234
|
+
}
|
|
235
|
+
if (received >= maxBytes)
|
|
236
|
+
cancel();
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
// The body failed mid-stream, or a runtime errored it on abort: what arrived stands.
|
|
104
240
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
throw new RejectedAssetError(`Storage refused the upload of "${label}" (${describeStatus(response, refusal)}): ${advice}`, label, status, { code });
|
|
241
|
+
finally {
|
|
242
|
+
abort.removeEventListener("abort", cancel);
|
|
108
243
|
}
|
|
109
|
-
|
|
110
|
-
(refusal.message ? `: ${refusal.message}` : "") +
|
|
111
|
-
". Retrying with the same grant either stores the file or reports the grant as used.", { status });
|
|
244
|
+
return text + decoder.decode();
|
|
112
245
|
}
|
|
113
246
|
/**
|
|
114
247
|
* The grant's URL, parsed before anything is sent. A runtime that cannot build a request
|
|
@@ -131,7 +264,7 @@ function storageTarget(grant, label) {
|
|
|
131
264
|
target.password !== "") {
|
|
132
265
|
throw new UploadTransportError(`Upload of "${label}" was not sent: the grant's url is not an absolute http(s) URL ` +
|
|
133
266
|
"free of user info, so it is not the one requestUploadGrant returned. Pass the grant " +
|
|
134
|
-
"on unchanged.");
|
|
267
|
+
"on unchanged.", { code: "invalid_grant_url" });
|
|
135
268
|
}
|
|
136
269
|
return target;
|
|
137
270
|
}
|
package/dist/upload-grant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-grant.js","sourceRoot":"","sources":["../src/upload-grant.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"upload-grant.js","sourceRoot":"","sources":["../src/upload-grant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG9F,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG/D,6FAA6F;AAC7F,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG9F;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,gCAAgC,GAAG,GAAG,GAAG,IAAI,CAAC;AAEpD;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,CAAC;AA0BvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,CAAC,KAAK,UAAU,eA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;IACD,IAAI,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACxD,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE,wBAAwB,KAAK,CAAC,UAAU,wBAAwB;SACzE,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3D,OAAO;YACL,IAAI,EAAE,iBAAiB;YACvB,MAAM,EACJ,oFAAoF;gBACpF,0BAA0B;SAC7B,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,MAAM,EACJ,OAAO,CAAC,OAAO;YACf,8EAA8E;KACjF,CAAC;AACJ,CAAC;AAED,kGAAkG;AAClG,SAAS,SAAS,CAAC,KAAkB,EAAE,IAAU;IAC/C,MAAM,IAAI,GAAI,IAA2B,CAAC,IAAI,CAAC;IAC/C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7D,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7D,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;AAC5C,CAAC"}
|
package/dist/upload.js
CHANGED
|
@@ -135,11 +135,17 @@ function mapUploadError(error, filename) {
|
|
|
135
135
|
return new UnsupportedUploadCapabilityError("The configured Pipelex deployment does not support file upload (no /v1/upload route). " +
|
|
136
136
|
"Upload is a hosted Pipelex capability.", { cause: error });
|
|
137
137
|
default:
|
|
138
|
-
return new UploadTransportError(`Upload of "${filename}" failed (${error.status}): ${error.serverMessage ?? error.statusText}.`, {
|
|
138
|
+
return new UploadTransportError(`Upload of "${filename}" failed (${error.status}): ${error.serverMessage ?? error.statusText}.`, {
|
|
139
|
+
cause: error,
|
|
140
|
+
status: error.status,
|
|
141
|
+
code: error.status >= 500 ? "server_error" : "unexpected",
|
|
142
|
+
});
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
if (error instanceof ApiUnreachableError) {
|
|
142
|
-
return new UploadTransportError(`Upload of "${filename}" could not reach the Pipelex API (${error.code ?? "unreachable"}).`,
|
|
146
|
+
return new UploadTransportError(`Upload of "${filename}" could not reach the Pipelex API (${error.code ?? "unreachable"}).`,
|
|
147
|
+
// The client's own request timeout surfaces as an unreachable host with this code.
|
|
148
|
+
{ cause: error, code: error.code === "ABORT_TIMEOUT" ? "timeout" : "unreachable" });
|
|
143
149
|
}
|
|
144
150
|
// Only errors thrown by the `client.upload()` call reach here — the local-source
|
|
145
151
|
// and asset-type failures are raised in `toAssetBytes`, before this try block. Any
|
|
@@ -149,6 +155,7 @@ function mapUploadError(error, filename) {
|
|
|
149
155
|
const detail = error instanceof Error ? error.message : String(error);
|
|
150
156
|
return new UploadTransportError(`Upload of "${filename}" failed unexpectedly: ${detail}.`, {
|
|
151
157
|
cause: error,
|
|
158
|
+
code: "unexpected",
|
|
152
159
|
});
|
|
153
160
|
}
|
|
154
161
|
//# sourceMappingURL=upload.js.map
|
package/dist/upload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,gCAAgC,GACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAmCpE,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AACxD,MAAM,gBAAgB,GA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