Skip to content

Commit 1748475

Browse files
committed
fixes
1 parent e918234 commit 1748475

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

js/botasaurus-server-js/src/worker-executor.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,21 @@ export class WorkerExecutor extends TaskExecutor {
320320
parentTaskId: number | null,
321321
key: string,
322322
): Promise<void> {
323-
this.inProgressTaskIds.delete(taskId);
323+
324324

325325
// Determine optimal chunk size based on file size and item count
326326
const chunkSize = determineChunkSize(taskFilePath, itemCount);
327327

328+
// If all items fit in a single chunk, use simpler reportTaskSuccess
329+
if (chunkSize >= itemCount) {
330+
const allItems: any[] = [];
331+
await readNdJsonCallback(taskFilePath, async (item) => {
332+
allItems.push(item);
333+
});
334+
return this.reportTaskSuccess(taskId, allItems, isResultDontCached, scraperName, taskData, parentTaskId, key);
335+
}
336+
337+
this.inProgressTaskIds.delete(taskId);
328338
// Stream chunks to master (outside mutex to allow other operations)
329339
let chunk: any[] = [];
330340

0 commit comments

Comments
 (0)