react-native-update-cli 2.27.1 → 2.28.1
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/lib/api.js
CHANGED
|
@@ -216,11 +216,12 @@ exports.get = queryWithoutBody('GET');
|
|
|
216
216
|
exports.post = queryWithBody('POST');
|
|
217
217
|
exports.put = queryWithBody('PUT');
|
|
218
218
|
exports.doDelete = queryWithBody('DELETE');
|
|
219
|
-
// Upload deadline: generous for a slow link (
|
|
220
|
-
// never below 60 s) but bounded, so a stalled connection cannot
|
|
221
|
-
// forever. The bar keeps ticking while bytes flow; the deadline
|
|
219
|
+
// Upload deadline: generous for a slow link (5 s/MB, i.e. ~200 KB/s, on top
|
|
220
|
+
// of a 30 s base, never below 60 s) but bounded, so a stalled connection cannot
|
|
221
|
+
// hang a CI job forever. The bar keeps ticking while bytes flow; the deadline
|
|
222
|
+
// is absolute.
|
|
222
223
|
const UPLOAD_TIMEOUT_BASE_MS = 30_000;
|
|
223
|
-
const UPLOAD_TIMEOUT_PER_MB_MS =
|
|
224
|
+
const UPLOAD_TIMEOUT_PER_MB_MS = 5_000;
|
|
224
225
|
const UPLOAD_TIMEOUT_MIN_MS = 60_000;
|
|
225
226
|
const UPLOAD_MAX_RETRIES = 1;
|
|
226
227
|
function uploadTimeoutMs(fileSize) {
|
|
@@ -262,12 +263,12 @@ function loadNodeFetch() {
|
|
|
262
263
|
return (mod.default ?? mod);
|
|
263
264
|
}
|
|
264
265
|
/**
|
|
265
|
-
* Send the file with a size-scaled deadline and
|
|
266
|
-
* network error. `buildRequest` is invoked per attempt with a
|
|
267
|
-
* stream (a consumed stream/form cannot be replayed).
|
|
266
|
+
* Send the file (or one slice of it) with a size-scaled deadline and retries
|
|
267
|
+
* on a transient network error. `buildRequest` is invoked per attempt with a
|
|
268
|
+
* fresh file stream (a consumed stream/form cannot be replayed).
|
|
268
269
|
*/
|
|
269
|
-
async function sendUpload(fn, realUrl, fileSize, bar, buildRequest) {
|
|
270
|
-
const timeoutMs = uploadTimeoutMs(
|
|
270
|
+
async function sendUpload(fn, realUrl, fileSize, bar, buildRequest, slice = { start: 0, end: fileSize, retries: UPLOAD_MAX_RETRIES }) {
|
|
271
|
+
const timeoutMs = uploadTimeoutMs(slice.end - slice.start);
|
|
271
272
|
const nodeFetch = loadNodeFetch();
|
|
272
273
|
// HTTP(S)_PROXY / NO_PROXY, like every other request of the CLI
|
|
273
274
|
const agent = (0, runtime_1.proxyAgentFor)(realUrl);
|
|
@@ -278,8 +279,14 @@ async function sendUpload(fn, realUrl, fileSize, bar, buildRequest) {
|
|
|
278
279
|
timedOut = true;
|
|
279
280
|
controller.abort();
|
|
280
281
|
}, timeoutMs);
|
|
281
|
-
const fileStream = fs_1.default.createReadStream(fn
|
|
282
|
+
const fileStream = fs_1.default.createReadStream(fn, {
|
|
283
|
+
start: slice.start,
|
|
284
|
+
// an empty file has no last byte; end = start reads nothing
|
|
285
|
+
end: Math.max(slice.start, slice.end - 1),
|
|
286
|
+
});
|
|
287
|
+
let sent = 0;
|
|
282
288
|
fileStream.on('data', (data) => {
|
|
289
|
+
sent += data.length;
|
|
283
290
|
bar.tick(data.length);
|
|
284
291
|
});
|
|
285
292
|
try {
|
|
@@ -292,11 +299,11 @@ async function sendUpload(fn, realUrl, fileSize, bar, buildRequest) {
|
|
|
292
299
|
catch (rawError) {
|
|
293
300
|
fileStream.destroy();
|
|
294
301
|
const error = timedOut ? new UploadTimeoutError(timeoutMs) : rawError;
|
|
295
|
-
if (attempt <
|
|
302
|
+
if (attempt < slice.retries && isTransientUploadError(error)) {
|
|
296
303
|
const reason = error instanceof Error ? error.message : String(error);
|
|
297
304
|
console.warn(`\nUpload interrupted (${reason}), retrying...`);
|
|
298
|
-
//
|
|
299
|
-
bar.curr = 0;
|
|
305
|
+
// take this attempt's bytes back off the bar before the next pass
|
|
306
|
+
bar.curr = Math.max(0, bar.curr - sent);
|
|
300
307
|
continue;
|
|
301
308
|
}
|
|
302
309
|
throw error;
|
|
@@ -306,16 +313,56 @@ async function sendUpload(fn, realUrl, fileSize, bar, buildRequest) {
|
|
|
306
313
|
}
|
|
307
314
|
}
|
|
308
315
|
}
|
|
316
|
+
/** Parts in flight at once; each is its own TCP connection. */
|
|
317
|
+
const CHUNK_CONCURRENCY = 4;
|
|
318
|
+
/** A part is small, so it can afford more retries than the whole file. */
|
|
319
|
+
const CHUNK_MAX_RETRIES = 2;
|
|
320
|
+
/** A part the store answered with an HTTP error: retrying will not help. */
|
|
321
|
+
class ChunkRejectedError extends Error {
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Post the parts of a chunked upload, CHUNK_CONCURRENCY at a time. The first
|
|
325
|
+
* failure stops scheduling new parts; the ones in flight finish, then it is
|
|
326
|
+
* thrown.
|
|
327
|
+
*/
|
|
328
|
+
async function sendChunks(fn, realUrl, fileSize, bar, chunked, postForm) {
|
|
329
|
+
let next = 0;
|
|
330
|
+
let failure;
|
|
331
|
+
const worker = async () => {
|
|
332
|
+
while (failure === undefined && next < chunked.parts.length) {
|
|
333
|
+
const index = next++;
|
|
334
|
+
const start = index * chunked.partSize;
|
|
335
|
+
const end = Math.min(fileSize, start + chunked.partSize);
|
|
336
|
+
try {
|
|
337
|
+
const res = await sendUpload(fn, realUrl, fileSize, bar, postForm(chunked.parts[index], end - start), { start, end, retries: CHUNK_MAX_RETRIES });
|
|
338
|
+
if (res.status > 299) {
|
|
339
|
+
throw new ChunkRejectedError(`${res.status}: ${res.statusText || 'Upload failed'} (part ${index + 1}/${chunked.parts.length})`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
failure ??= error;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
await Promise.all(Array.from({ length: Math.min(CHUNK_CONCURRENCY, chunked.parts.length) }, worker));
|
|
348
|
+
if (failure !== undefined) {
|
|
349
|
+
throw failure;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
309
352
|
async function uploadFile(fn, key, appId) {
|
|
353
|
+
const fileSize = fs_1.default.statSync(fn).size;
|
|
310
354
|
// appId 用于服务端路由:绑定了自托管节点(rnu-node)的应用,
|
|
311
|
-
//
|
|
355
|
+
// 上传指令会指向节点或其对象存储。chunked + size 让支持的服务端(GCS)
|
|
356
|
+
// 改发分片并行上传的指令;不认识这两个字段的服务端照旧整文件上传
|
|
312
357
|
const resp = await (0, exports.post)('/upload', {
|
|
313
358
|
ext: path_1.default.extname(fn),
|
|
314
359
|
...(appId ? { appId: Number(appId) } : {}),
|
|
360
|
+
...(key ? {} : { chunked: true, size: fileSize }),
|
|
315
361
|
});
|
|
316
362
|
const { url, backupUrl, formData, maxSize } = resp;
|
|
317
363
|
let realUrl = url;
|
|
318
|
-
|
|
364
|
+
// GCS hands out the same url twice: nothing to switch to, no probe needed
|
|
365
|
+
if (backupUrl && backupUrl !== url) {
|
|
319
366
|
if (global.USE_ACC_OSS) {
|
|
320
367
|
realUrl = backupUrl;
|
|
321
368
|
}
|
|
@@ -332,7 +379,6 @@ async function uploadFile(fn, key, appId) {
|
|
|
332
379
|
}
|
|
333
380
|
// console.log({realUrl});
|
|
334
381
|
}
|
|
335
|
-
const fileSize = fs_1.default.statSync(fn).size;
|
|
336
382
|
if (maxSize && fileSize > (0, filesize_parser_1.default)(maxSize)) {
|
|
337
383
|
const readableFileSize = `${(fileSize / 1048576).toFixed(1)}m`;
|
|
338
384
|
throw new Error((0, i18n_1.t)('fileSizeExceeded', {
|
|
@@ -342,7 +388,9 @@ async function uploadFile(fn, key, appId) {
|
|
|
342
388
|
}));
|
|
343
389
|
}
|
|
344
390
|
// progress/form-data are only needed here; keep them off the startup path
|
|
345
|
-
const
|
|
391
|
+
const progressModule = require('progress');
|
|
392
|
+
const ProgressBarImpl = (progressModule.default ??
|
|
393
|
+
progressModule);
|
|
346
394
|
const bar = new ProgressBarImpl(' Uploading [:bar] :percent :etas', {
|
|
347
395
|
complete: '=',
|
|
348
396
|
incomplete: ' ',
|
|
@@ -377,23 +425,40 @@ async function uploadFile(fn, key, appId) {
|
|
|
377
425
|
}
|
|
378
426
|
return { hash: resp.key };
|
|
379
427
|
}
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
428
|
+
const formDataModule = require('form-data');
|
|
429
|
+
const FormData = (formDataModule.default ??
|
|
430
|
+
formDataModule);
|
|
431
|
+
const postForm = (fields, byteCount) => (fileStream) => {
|
|
432
|
+
const form = new FormData();
|
|
433
|
+
for (const [k, v] of Object.entries(fields)) {
|
|
434
|
+
form.append(k, v);
|
|
435
|
+
}
|
|
436
|
+
// With every part's length known node-fetch sends Content-Length
|
|
437
|
+
// instead of a chunked body: what object stores expect, and the only
|
|
438
|
+
// framing that survives http-proxy-agent's rewrite of the buffered
|
|
439
|
+
// request head.
|
|
440
|
+
form.append('file', fileStream, { knownLength: byteCount });
|
|
441
|
+
return { method: 'POST', body: form };
|
|
442
|
+
};
|
|
443
|
+
if (resp.chunked && !key) {
|
|
444
|
+
try {
|
|
445
|
+
await sendChunks(fn, realUrl, fileSize, bar, resp.chunked, postForm);
|
|
446
|
+
}
|
|
447
|
+
catch (error) {
|
|
448
|
+
if (error instanceof ChunkRejectedError) {
|
|
449
|
+
throw createRequestError(error.message, realUrl);
|
|
390
450
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
451
|
+
return rethrowUploadError(error);
|
|
452
|
+
}
|
|
453
|
+
await (0, exports.post)('/upload/complete', {
|
|
454
|
+
key: resp.chunked.key,
|
|
455
|
+
parts: resp.chunked.parts.length,
|
|
396
456
|
});
|
|
457
|
+
return { hash: resp.chunked.key };
|
|
458
|
+
}
|
|
459
|
+
let res;
|
|
460
|
+
try {
|
|
461
|
+
res = await sendUpload(fn, realUrl, fileSize, bar, postForm(key ? { ...formData, key } : formData, fileSize));
|
|
397
462
|
}
|
|
398
463
|
catch (error) {
|
|
399
464
|
return rethrowUploadError(error);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace the parts of a detail line that can only come from the user's code:
|
|
3
|
+
* quoted string operands (property names, string literals), function names,
|
|
4
|
+
* and filesystem paths that reach the line through a compiler's stderr. What
|
|
5
|
+
* stays is the shape a fix is reasoned about -- opcodes, registers, counts,
|
|
6
|
+
* literal kinds -- plus each redacted value's length and character class.
|
|
7
|
+
*
|
|
8
|
+
* This is redaction by class, not a proof: it covers the shapes the comparison
|
|
9
|
+
* and the compilers are known to emit. Anything that arrives in an unknown
|
|
10
|
+
* shape still has its paths and quoted runs stripped, so a new detail format
|
|
11
|
+
* cannot silently start leaking identifiers.
|
|
12
|
+
*/
|
|
13
|
+
export declare function redactFailureDetail(detail: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* The grouping key: a redacted detail with everything that varies between two
|
|
16
|
+
* occurrences of the same defect removed -- registers, ids, offsets, labels,
|
|
17
|
+
* counts and the redaction tokens themselves. Sixteen bytes; the server stores
|
|
18
|
+
* it as 32 hex characters.
|
|
19
|
+
*/
|
|
20
|
+
export declare function failureFingerprint(detail: string): string;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redactFailureDetail = redactFailureDetail;
|
|
4
|
+
exports.failureFingerprint = failureFingerprint;
|
|
5
|
+
/**
|
|
6
|
+
* One implementation of the failure fingerprint, shared by everything that
|
|
7
|
+
* groups the same failure: the version/create report, the fuzzer's dedup of
|
|
8
|
+
* its findings, and (later) the replay of the stored corpus. Two
|
|
9
|
+
* implementations would mean the counts behind "how often does this happen"
|
|
10
|
+
* are fiction, so callers import from here rather than writing their own
|
|
11
|
+
* regexes.
|
|
12
|
+
*
|
|
13
|
+
* Redaction is the other half. A detail line carries whatever hermesc printed,
|
|
14
|
+
* which is the user's own code: the first rejection seen in production named
|
|
15
|
+
* the property `promotionRequestItemId`. Details travel to the server, into
|
|
16
|
+
* issue lists and -- once the fix loop runs -- into public pull requests and CI
|
|
17
|
+
* fixtures, so the identifiers are replaced by tokens *before* the report
|
|
18
|
+
* leaves the machine. The local console keeps the unredacted text: that is
|
|
19
|
+
* where the name is actually useful.
|
|
20
|
+
*/
|
|
21
|
+
const node_crypto_1 = require("node:crypto");
|
|
22
|
+
const sha = (value) => (0, node_crypto_1.createHash)('sha256').update(value).digest('hex');
|
|
23
|
+
/** stable stand-in for one redacted value; the same input always yields it */
|
|
24
|
+
const token = (kind, value) => `${kind}#${sha(value).slice(0, 8)}`;
|
|
25
|
+
/**
|
|
26
|
+
* Replace the parts of a detail line that can only come from the user's code:
|
|
27
|
+
* quoted string operands (property names, string literals), function names,
|
|
28
|
+
* and filesystem paths that reach the line through a compiler's stderr. What
|
|
29
|
+
* stays is the shape a fix is reasoned about -- opcodes, registers, counts,
|
|
30
|
+
* literal kinds -- plus each redacted value's length and character class.
|
|
31
|
+
*
|
|
32
|
+
* This is redaction by class, not a proof: it covers the shapes the comparison
|
|
33
|
+
* and the compilers are known to emit. Anything that arrives in an unknown
|
|
34
|
+
* shape still has its paths and quoted runs stripped, so a new detail format
|
|
35
|
+
* cannot silently start leaking identifiers.
|
|
36
|
+
*/
|
|
37
|
+
function redactFailureDetail(detail) {
|
|
38
|
+
return (detail
|
|
39
|
+
// Paths first: a compiler's stderr reaches the line with them, and
|
|
40
|
+
// running this pass after the others would eat the `/<length>` suffix
|
|
41
|
+
// the string pass writes.
|
|
42
|
+
.replace(/(?:\.{0,2}\/)[^\s:,)"']*/g, (path) => {
|
|
43
|
+
const ext = /\.([A-Za-z0-9]+)$/.exec(path);
|
|
44
|
+
return `${token('path', path)}${ext ? `.${ext[1]}` : ''}`;
|
|
45
|
+
})
|
|
46
|
+
// Function<name>(…) headers, including the raw-audit variants
|
|
47
|
+
.replace(/\b(Function|NCFunction|Constructor)<([^>]*)>/g, (_all, kind, name) => `${kind}<${name ? token('fn', name) : ''}>`)
|
|
48
|
+
// Quoted operands. hermesc does not escape quotes inside strings, so the
|
|
49
|
+
// run is taken as-is up to the next quote; a stray tail keeps whatever
|
|
50
|
+
// the earlier passes left rather than being reconstructed.
|
|
51
|
+
.replace(/"([^"\n]*)"/g, (_all, value) => {
|
|
52
|
+
const units = Array.from(value);
|
|
53
|
+
const ascii = units.every((char) => char.charCodeAt(0) < 0x80);
|
|
54
|
+
return `"${token('str', value)}/${units.length}${ascii ? '' : '/u16'}"`;
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The grouping key: a redacted detail with everything that varies between two
|
|
59
|
+
* occurrences of the same defect removed -- registers, ids, offsets, labels,
|
|
60
|
+
* counts and the redaction tokens themselves. Sixteen bytes; the server stores
|
|
61
|
+
* it as 32 hex characters.
|
|
62
|
+
*/
|
|
63
|
+
function failureFingerprint(detail) {
|
|
64
|
+
const shape = redactFailureDetail(detail)
|
|
65
|
+
.replace(/#[0-9a-f]{8}/g, '#')
|
|
66
|
+
.replace(/\br\d+\b/g, 'r')
|
|
67
|
+
.replace(/\bL\d+\b/g, 'L')
|
|
68
|
+
.replace(/\d+/g, 'N')
|
|
69
|
+
.replace(/\s+/g, ' ')
|
|
70
|
+
.trim();
|
|
71
|
+
return sha(shape).slice(0, 32);
|
|
72
|
+
}
|
|
@@ -40,8 +40,17 @@ export interface HermesBaseMeta {
|
|
|
40
40
|
baseHash: string | null;
|
|
41
41
|
/** absent (never null) when the bundle step did not run hermesc */
|
|
42
42
|
hermesBaseOutcome?: HermesBaseOutcome;
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* First difference / failure reason, redacted (see redactFailureDetail):
|
|
45
|
+
* the raw text carries the user's own property and string names. Absent
|
|
46
|
+
* when there is none.
|
|
47
|
+
*/
|
|
44
48
|
hermesBaseDetail?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Grouping key for the same defect across builds and apps, computed from
|
|
51
|
+
* the unredacted detail. Absent with the detail.
|
|
52
|
+
*/
|
|
53
|
+
hermesBaseFingerprint?: string;
|
|
45
54
|
}
|
|
46
55
|
/**
|
|
47
56
|
* Hermes V1 (static_h) builds before 2025-07-11 carried a delta-mode bug when a
|
package/lib/utils/hermes-base.js
CHANGED
|
@@ -81,6 +81,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
81
81
|
const stream_1 = require("stream");
|
|
82
82
|
const promises_1 = require("stream/promises");
|
|
83
83
|
const constants_1 = require("./constants");
|
|
84
|
+
const failure_fingerprint_1 = require("./failure-fingerprint");
|
|
84
85
|
const hbcTransform_1 = require("./hbcTransform");
|
|
85
86
|
const hermes_cached_object_1 = require("./hermes-cached-object");
|
|
86
87
|
const hermes_literals_1 = require("./hermes-literals");
|
|
@@ -817,9 +818,13 @@ function hermesBaseMeta(selection, bytecodeVersion, check) {
|
|
|
817
818
|
};
|
|
818
819
|
if (check) {
|
|
819
820
|
meta.hermesBaseOutcome = check.outcome;
|
|
820
|
-
|
|
821
|
-
|
|
821
|
+
// The console above keeps the real text -- that is where the property
|
|
822
|
+
// name helps. What leaves the machine is redacted and fingerprinted.
|
|
823
|
+
const detail = truncateHermesBaseDetail((0, failure_fingerprint_1.redactFailureDetail)(check.detail ?? ''));
|
|
824
|
+
if (detail) {
|
|
822
825
|
meta.hermesBaseDetail = detail;
|
|
826
|
+
meta.hermesBaseFingerprint = (0, failure_fingerprint_1.failureFingerprint)(check.detail ?? '');
|
|
827
|
+
}
|
|
823
828
|
}
|
|
824
829
|
return meta;
|
|
825
830
|
}
|
package/package.json
CHANGED