@tiens.nguyen/gonext-local-worker 1.0.22 → 1.0.23

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.
@@ -162,6 +162,10 @@ async function runChatJob(job) {
162
162
  /** Chains debounced chunk POSTs so we never PATCH `completed` while a chunk POST is still in flight. */
163
163
  let flushTail = Promise.resolve();
164
164
 
165
+ /** Batch streamed text: fewer HTTPS round-trips to the API than a 12ms debounce per flush. */
166
+ const CHUNK_DEBOUNCE_MS = 80;
167
+ const CHUNK_MAX_BUF = 6144;
168
+
165
169
  const flushChunks = async () => {
166
170
  const t = buf;
167
171
  buf = "";
@@ -199,13 +203,23 @@ async function runChatJob(job) {
199
203
  if (!s) return;
200
204
  fullText += s;
201
205
  buf += s;
206
+ if (buf.length >= CHUNK_MAX_BUF) {
207
+ if (flushTimer) {
208
+ clearTimeout(flushTimer);
209
+ flushTimer = null;
210
+ }
211
+ flushTail = flushTail.then(() => flushChunks()).catch((err) => {
212
+ console.error("[gonext-worker] chunk flush error:", err);
213
+ });
214
+ return;
215
+ }
202
216
  if (!flushTimer) {
203
217
  flushTimer = setTimeout(() => {
204
218
  flushTimer = null;
205
219
  flushTail = flushTail.then(() => flushChunks()).catch((err) => {
206
220
  console.error("[gonext-worker] chunk flush error:", err);
207
221
  });
208
- }, 12);
222
+ }, CHUNK_DEBOUNCE_MS);
209
223
  }
210
224
  };
211
225
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
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",