@series-inc/stowkit-cli 0.6.23 → 0.6.34
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/server.js +16 -3
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -55,6 +55,8 @@ function broadcast(msg) {
|
|
|
55
55
|
ws.send(data);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
/** Tracks the most recent fire-and-forget processing promise so wait=true can join it. */
|
|
59
|
+
let activeProcessingTask = null;
|
|
58
60
|
/**
|
|
59
61
|
* Single entry point for all processing orchestration.
|
|
60
62
|
* - Skips materials (they don't need processing)
|
|
@@ -136,10 +138,15 @@ function queueProcessing(opts = {}) {
|
|
|
136
138
|
}
|
|
137
139
|
broadcast({ type: 'processing-complete' });
|
|
138
140
|
})();
|
|
141
|
+
// Track the active task so wait=true callers can join in-flight processing
|
|
142
|
+
activeProcessingTask = task.finally(() => {
|
|
143
|
+
if (activeProcessingTask === task)
|
|
144
|
+
activeProcessingTask = null;
|
|
145
|
+
});
|
|
139
146
|
if (opts.await)
|
|
140
|
-
return
|
|
147
|
+
return activeProcessingTask;
|
|
141
148
|
// Fire-and-forget: log errors but don't block caller
|
|
142
|
-
|
|
149
|
+
activeProcessingTask.catch(err => console.error('[server] queueProcessing error:', err));
|
|
143
150
|
return Promise.resolve();
|
|
144
151
|
}
|
|
145
152
|
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
@@ -1028,10 +1035,16 @@ async function handleRequest(req, res, staticApps) {
|
|
|
1028
1035
|
json(res, { error: 'No project open' }, 400);
|
|
1029
1036
|
return;
|
|
1030
1037
|
}
|
|
1031
|
-
// If wait=true,
|
|
1038
|
+
// If wait=true, ensure all asset processing completes before building.
|
|
1039
|
+
// First join any in-flight processing, then start a new run for any remaining pending assets.
|
|
1032
1040
|
const body = await readBody(req).then(b => b ? JSON.parse(b) : {}).catch(() => ({}));
|
|
1033
1041
|
const wait = body.wait === true || url.searchParams.get('wait') === 'true';
|
|
1034
1042
|
if (wait) {
|
|
1043
|
+
// Await any already-running background processing
|
|
1044
|
+
if (activeProcessingTask) {
|
|
1045
|
+
await activeProcessingTask;
|
|
1046
|
+
}
|
|
1047
|
+
// Pick up any assets that became pending after the previous run
|
|
1035
1048
|
const pending = assets.filter(a => a.status === 'pending' || a.status === 'processing');
|
|
1036
1049
|
if (pending.length > 0) {
|
|
1037
1050
|
await queueProcessing({ await: true });
|