@tiens.nguyen/gonext-local-worker 1.0.19 → 1.0.22
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/gonext-local-worker.mjs +26 -8
- package/package.json +1 -1
package/gonext-local-worker.mjs
CHANGED
|
@@ -159,9 +159,10 @@ async function runChatJob(job) {
|
|
|
159
159
|
let buf = "";
|
|
160
160
|
let flushTimer = null;
|
|
161
161
|
let fullText = "";
|
|
162
|
+
/** Chains debounced chunk POSTs so we never PATCH `completed` while a chunk POST is still in flight. */
|
|
163
|
+
let flushTail = Promise.resolve();
|
|
162
164
|
|
|
163
165
|
const flushChunks = async () => {
|
|
164
|
-
flushTimer = null;
|
|
165
166
|
const t = buf;
|
|
166
167
|
buf = "";
|
|
167
168
|
if (!t) return;
|
|
@@ -172,15 +173,25 @@ async function runChatJob(job) {
|
|
|
172
173
|
if (!res.ok && res.status !== 204) {
|
|
173
174
|
const snippet = (await res.text().catch(() => "")).trim().slice(0, 400);
|
|
174
175
|
const url = `${apiBase}${CHUNK_PATH}`;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
);
|
|
179
|
-
if (res.status === 404) {
|
|
176
|
+
const benign409 =
|
|
177
|
+
res.status === 409 && snippet.includes('"jobStatus":"completed"');
|
|
178
|
+
if (!benign409) {
|
|
180
179
|
console.error(
|
|
181
|
-
|
|
180
|
+
`[gonext-worker] job-chunk POST failed status=${res.status} url=${url} jobId=${jobId}` +
|
|
181
|
+
(snippet ? ` response=${snippet}` : "")
|
|
182
182
|
);
|
|
183
183
|
}
|
|
184
|
+
if (res.status === 404) {
|
|
185
|
+
if (snippet.includes("Cannot POST")) {
|
|
186
|
+
console.error(
|
|
187
|
+
"[gonext-worker] DEPLOY: Lambda/API still runs old Express without POST /api/worker/job-chunk. From repo: cd api && npm ci && sam build && sam deploy — or publish the latest bundled handler so execute-api serves current routes."
|
|
188
|
+
);
|
|
189
|
+
} else {
|
|
190
|
+
console.error(
|
|
191
|
+
'[gonext-worker] hint: JSON {"error":"Job not found"} = Dynamo lookup failed (wrong worker user vs job owner). Otherwise redeploy API.'
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
184
195
|
}
|
|
185
196
|
};
|
|
186
197
|
|
|
@@ -189,7 +200,12 @@ async function runChatJob(job) {
|
|
|
189
200
|
fullText += s;
|
|
190
201
|
buf += s;
|
|
191
202
|
if (!flushTimer) {
|
|
192
|
-
flushTimer = setTimeout(() =>
|
|
203
|
+
flushTimer = setTimeout(() => {
|
|
204
|
+
flushTimer = null;
|
|
205
|
+
flushTail = flushTail.then(() => flushChunks()).catch((err) => {
|
|
206
|
+
console.error("[gonext-worker] chunk flush error:", err);
|
|
207
|
+
});
|
|
208
|
+
}, 12);
|
|
193
209
|
}
|
|
194
210
|
};
|
|
195
211
|
|
|
@@ -232,6 +248,7 @@ async function runChatJob(job) {
|
|
|
232
248
|
clearTimeout(flushTimer);
|
|
233
249
|
flushTimer = null;
|
|
234
250
|
}
|
|
251
|
+
await flushTail;
|
|
235
252
|
await flushChunks();
|
|
236
253
|
|
|
237
254
|
const totalTimeSeconds = (Date.now() - start) / 1000;
|
|
@@ -250,6 +267,7 @@ async function runChatJob(job) {
|
|
|
250
267
|
clearTimeout(flushTimer);
|
|
251
268
|
flushTimer = null;
|
|
252
269
|
}
|
|
270
|
+
await flushTail;
|
|
253
271
|
await flushChunks().catch(() => {});
|
|
254
272
|
const message = e instanceof Error ? e.message : String(e);
|
|
255
273
|
await workerFetch(`/api/worker/jobs/${jobId}`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiens.nguyen/gonext-local-worker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "Polls GoNext cloud API for async local LLM jobs and runs them against Ollama/OpenAI-compatible servers on this Mac",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|