@editframe/assets 0.18.8-beta.0 → 0.18.19-beta.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/generateSingleTrack.js +21 -16
- package/package.json +1 -1
|
@@ -44,25 +44,30 @@ const generateSingleTrackTask = idempotentTask({
|
|
|
44
44
|
runner: async (absolutePath, trackId) => {
|
|
45
45
|
const result = await generateSingleTrackFromPath(absolutePath, trackId);
|
|
46
46
|
const finalStream = new PassThrough();
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const checkCompletion = () => {
|
|
50
|
-
if (streamEnded && fragmentIndexCompleted) finalStream.end();
|
|
51
|
-
};
|
|
52
|
-
result.stream.pipe(finalStream, { end: false });
|
|
53
|
-
result.stream.on("end", () => {
|
|
54
|
-
streamEnded = true;
|
|
55
|
-
checkCompletion();
|
|
47
|
+
const fragmentIndexPromise = result.fragmentIndex.catch((error) => {
|
|
48
|
+
console.warn(`Fragment index generation failed for track ${trackId}:`, error);
|
|
56
49
|
});
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
let progressTimeout = null;
|
|
51
|
+
const resetProgressTimeout = () => {
|
|
52
|
+
if (progressTimeout) clearTimeout(progressTimeout);
|
|
53
|
+
progressTimeout = setTimeout(() => {
|
|
54
|
+
if (!finalStream.destroyed) {
|
|
55
|
+
console.warn(`Progress timeout triggered for track ${trackId} - no activity for 10 seconds`);
|
|
56
|
+
finalStream.end();
|
|
57
|
+
}
|
|
58
|
+
}, 1e4);
|
|
59
|
+
};
|
|
60
|
+
resetProgressTimeout();
|
|
61
|
+
result.stream.on("data", () => {
|
|
62
|
+
resetProgressTimeout();
|
|
59
63
|
});
|
|
60
|
-
result.
|
|
61
|
-
|
|
62
|
-
checkCompletion();
|
|
63
|
-
}).catch((error) => {
|
|
64
|
-
finalStream.destroy(error);
|
|
64
|
+
result.stream.on("end", () => {
|
|
65
|
+
resetProgressTimeout();
|
|
65
66
|
});
|
|
67
|
+
result.stream.pipe(finalStream, { end: false });
|
|
68
|
+
await fragmentIndexPromise;
|
|
69
|
+
finalStream.end();
|
|
70
|
+
if (progressTimeout) clearTimeout(progressTimeout);
|
|
66
71
|
return finalStream;
|
|
67
72
|
}
|
|
68
73
|
});
|