@autocodeflow/cli 1.5.1 → 1.5.2
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/commands/exec.js +28 -0
- package/package.json +1 -1
package/dist/commands/exec.js
CHANGED
|
@@ -143,11 +143,38 @@ function execCommand() {
|
|
|
143
143
|
process.stdout.write(msg.data + '\n');
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
|
+
// D1-P2-3: 客户端空闲兜底。SSE 长连在反代静默丢包 / 执行器卡死 /
|
|
147
|
+
// 网络静默分区时既不 end 也不发帧——旧代码会永久挂起(CI/脚本里 tail
|
|
148
|
+
// 永不返回)。自收到首帧起,任意数据帧重置窗口;连续 60s 无任何数据帧
|
|
149
|
+
// 即判静默,以非零码退出并提示重连。
|
|
150
|
+
const IDLE_TIMEOUT_MS = 60000;
|
|
151
|
+
let idleTimer;
|
|
152
|
+
const armIdleTimer = () => {
|
|
153
|
+
if (idleTimer)
|
|
154
|
+
clearTimeout(idleTimer);
|
|
155
|
+
idleTimer = setTimeout(() => {
|
|
156
|
+
process.stderr.write(chalk_1.default.red(`[tail] no data frame for ${IDLE_TIMEOUT_MS / 1000}s — the stream went silent; retry \`acf exec tail ${execId}\`.\n`));
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}, IDLE_TIMEOUT_MS);
|
|
159
|
+
// unref:看门狗不得阻止进程在无其他活动句柄时退出(生产上流挂死
|
|
160
|
+
// 不绑架退出;测试里不残留挂起定时器拖慢 vitest)。
|
|
161
|
+
if (typeof idleTimer.unref === 'function')
|
|
162
|
+
idleTimer.unref();
|
|
163
|
+
};
|
|
164
|
+
const clearIdleTimer = () => {
|
|
165
|
+
if (idleTimer) {
|
|
166
|
+
clearTimeout(idleTimer);
|
|
167
|
+
idleTimer = undefined;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
armIdleTimer();
|
|
146
171
|
const stream = res.data;
|
|
147
172
|
stream.on('data', (chunk) => {
|
|
173
|
+
armIdleTimer(); // 任意数据帧(含心跳注释行)都重置空闲窗口
|
|
148
174
|
parser.feed(chunk.toString('utf-8'));
|
|
149
175
|
});
|
|
150
176
|
stream.on('end', () => {
|
|
177
|
+
clearIdleTimer();
|
|
151
178
|
if (sawDone) {
|
|
152
179
|
process.exit(0);
|
|
153
180
|
// 防穿透:测试里 process.exit 常被钉成桩(正常返回),结构上
|
|
@@ -162,6 +189,7 @@ function execCommand() {
|
|
|
162
189
|
process.exitCode = 1;
|
|
163
190
|
});
|
|
164
191
|
stream.on('error', (err) => {
|
|
192
|
+
clearIdleTimer();
|
|
165
193
|
process.stderr.write(chalk_1.default.red(`[tail] stream error: ${err.message}\n`));
|
|
166
194
|
process.exit(1);
|
|
167
195
|
});
|