@lark-apaas/fullstack-cli 1.1.59-alpha.20260720184331 → 1.1.59-alpha.20260721044121
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.
|
@@ -6,6 +6,7 @@ const net = require('net');
|
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const {
|
|
8
8
|
MAX_EVENT_BYTES,
|
|
9
|
+
createFallbackSessionID,
|
|
9
10
|
createPreviewPhaseOutbox,
|
|
10
11
|
} = require('./preview-phase-outbox.cjs');
|
|
11
12
|
|
|
@@ -88,6 +89,8 @@ function createPreviewPhaseReporter(options = {}) {
|
|
|
88
89
|
}
|
|
89
90
|
});
|
|
90
91
|
const producerInstanceID = randomUUID();
|
|
92
|
+
const fallbackSessionID =
|
|
93
|
+
options.fallback_session_id || createFallbackSessionID(randomUUID);
|
|
91
94
|
const runId = env.MIAODA_PREVIEW_RUN_ID || '';
|
|
92
95
|
let outbox = null;
|
|
93
96
|
let outboxInitializationError = null;
|
|
@@ -97,9 +100,15 @@ function createPreviewPhaseReporter(options = {}) {
|
|
|
97
100
|
root: options.outbox_root || env.MIAODA_PREVIEW_PHASE_OUTBOX_ROOT,
|
|
98
101
|
run_id: runId,
|
|
99
102
|
producer_epoch: env.MIAODA_PREVIEW_PHASE_PRODUCER_EPOCH,
|
|
103
|
+
expected_instance_id: env.MIAODA_PREVIEW_PHASE_INSTANCE_ID,
|
|
104
|
+
writer_instance_id: producerInstanceID,
|
|
105
|
+
producer_instance_id: producerInstanceID,
|
|
106
|
+
fallback_session_id: fallbackSessionID,
|
|
100
107
|
process_start_ticks: options.process_start_ticks,
|
|
101
108
|
get_process_start_ticks: options.get_process_start_ticks,
|
|
102
109
|
fs: options.fs,
|
|
110
|
+
register_producer: options.register_producer,
|
|
111
|
+
spawn_sync: options.spawn_sync,
|
|
103
112
|
random_uuid: randomUUID,
|
|
104
113
|
now,
|
|
105
114
|
});
|
|
@@ -108,8 +117,10 @@ function createPreviewPhaseReporter(options = {}) {
|
|
|
108
117
|
}
|
|
109
118
|
}
|
|
110
119
|
const producerSequences = new Map();
|
|
120
|
+
let fallbackSequence = 0;
|
|
111
121
|
const startupTerminalPhases = new Set();
|
|
112
122
|
let reporterSealed = false;
|
|
123
|
+
let quiesceAcknowledged = false;
|
|
113
124
|
let terminalCloseScheduled = false;
|
|
114
125
|
let quiescePollTimer = null;
|
|
115
126
|
|
|
@@ -184,8 +195,17 @@ function createPreviewPhaseReporter(options = {}) {
|
|
|
184
195
|
return false;
|
|
185
196
|
}
|
|
186
197
|
let persisted = false;
|
|
198
|
+
// Stdout remains a diagnostic mirror. Only canonical append success or a
|
|
199
|
+
// fallback event fdatasync is delivery proof.
|
|
200
|
+
let fallbackSpoolPersisted = false;
|
|
187
201
|
if (!outbox) {
|
|
188
202
|
event.transport = 'stdout_fallback';
|
|
203
|
+
reportDiagnostic({
|
|
204
|
+
code: 'stdout_fallback_untracked',
|
|
205
|
+
run_id: runId,
|
|
206
|
+
phase,
|
|
207
|
+
event_id: event.event_id,
|
|
208
|
+
});
|
|
189
209
|
} else {
|
|
190
210
|
try {
|
|
191
211
|
persisted = outbox.append(event);
|
|
@@ -200,7 +220,40 @@ function createPreviewPhaseReporter(options = {}) {
|
|
|
200
220
|
});
|
|
201
221
|
return false;
|
|
202
222
|
}
|
|
203
|
-
|
|
223
|
+
const nextFallbackSequence = fallbackSequence + 1;
|
|
224
|
+
event.transport = 'fallback_spool';
|
|
225
|
+
event.fallback_session_id = fallbackSessionID;
|
|
226
|
+
event.fallback_seq = nextFallbackSequence;
|
|
227
|
+
try {
|
|
228
|
+
fallbackSpoolPersisted = outbox.append_fallback(event);
|
|
229
|
+
if (fallbackSpoolPersisted) {
|
|
230
|
+
fallbackSequence = nextFallbackSequence;
|
|
231
|
+
}
|
|
232
|
+
} catch (fallbackError) {
|
|
233
|
+
if (fallbackError?.code !== 'PREVIEW_PHASE_EVENT_TOO_LARGE') {
|
|
234
|
+
reportDiagnostic({
|
|
235
|
+
code: 'fallback_spool_failed',
|
|
236
|
+
run_id: runId,
|
|
237
|
+
phase,
|
|
238
|
+
event_id: event.event_id,
|
|
239
|
+
error:
|
|
240
|
+
fallbackError instanceof Error
|
|
241
|
+
? fallbackError.message
|
|
242
|
+
: String(fallbackError),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (!fallbackSpoolPersisted) {
|
|
247
|
+
event.transport = 'stdout_fallback';
|
|
248
|
+
delete event.fallback_session_id;
|
|
249
|
+
delete event.fallback_seq;
|
|
250
|
+
reportDiagnostic({
|
|
251
|
+
code: 'stdout_fallback_untracked',
|
|
252
|
+
run_id: runId,
|
|
253
|
+
phase,
|
|
254
|
+
event_id: event.event_id,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
204
257
|
if (error?.code !== 'PREVIEW_PHASE_OUTBOX_DEGRADED') {
|
|
205
258
|
reportDiagnostic({
|
|
206
259
|
code: 'outbox_append_failed',
|
|
@@ -223,10 +276,8 @@ function createPreviewPhaseReporter(options = {}) {
|
|
|
223
276
|
});
|
|
224
277
|
return false;
|
|
225
278
|
}
|
|
226
|
-
let mirrored = false;
|
|
227
279
|
try {
|
|
228
280
|
write(`${PREFIX}${serializedEvent}`);
|
|
229
|
-
mirrored = true;
|
|
230
281
|
} catch (error) {
|
|
231
282
|
reportDiagnostic({
|
|
232
283
|
code: 'stdout_mirror_failed',
|
|
@@ -236,7 +287,11 @@ function createPreviewPhaseReporter(options = {}) {
|
|
|
236
287
|
error: error instanceof Error ? error.message : String(error),
|
|
237
288
|
});
|
|
238
289
|
}
|
|
239
|
-
const delivered = persisted ||
|
|
290
|
+
const delivered = persisted || fallbackSpoolPersisted;
|
|
291
|
+
if (delivered && outbox?.is_local_sealed?.()) {
|
|
292
|
+
reporterSealed = true;
|
|
293
|
+
stopQuiescePolling();
|
|
294
|
+
}
|
|
240
295
|
if (
|
|
241
296
|
delivered &&
|
|
242
297
|
status !== 'start' &&
|
|
@@ -332,15 +387,16 @@ function createPreviewPhaseReporter(options = {}) {
|
|
|
332
387
|
}
|
|
333
388
|
|
|
334
389
|
function pollQuiesce() {
|
|
335
|
-
if (reporterSealed) return
|
|
390
|
+
if (reporterSealed) return quiesceAcknowledged;
|
|
336
391
|
if (!outbox) return false;
|
|
337
392
|
try {
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
393
|
+
const quiesce = outbox.poll_quiesce();
|
|
394
|
+
if (quiesce.local_sealed) {
|
|
340
395
|
reporterSealed = true;
|
|
396
|
+
quiesceAcknowledged = quiesce.canonical_acknowledged;
|
|
341
397
|
stopQuiescePolling();
|
|
342
398
|
}
|
|
343
|
-
return
|
|
399
|
+
return quiesce.canonical_acknowledged;
|
|
344
400
|
} catch (error) {
|
|
345
401
|
reportDiagnostic({
|
|
346
402
|
code: 'outbox_quiesce_failed',
|