Skip to content

Commit

Permalink
Remove initial timeout, the batch timeout is now always 250ms (#1184)
Browse files Browse the repository at this point in the history
Standardize with the Python SDK, the delay for batch flushing in
multipart JS should also be 250ms

---------

Co-authored-by: jacoblee93 <[email protected]>
  • Loading branch information
nhuang-lc and jacoblee93 authored Nov 7, 2024
1 parent 9fb8288 commit a8cab88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
18 changes: 5 additions & 13 deletions js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,7 @@ export class Client {

private autoBatchTimeout: ReturnType<typeof setTimeout> | undefined;

private autoBatchInitialDelayMs = 250;

private autoBatchAggregationDelayMs = 50;
private autoBatchAggregationDelayMs = 250;

private batchSizeBytesLimit?: number;

Expand Down Expand Up @@ -802,7 +800,6 @@ export class Client {
}

private async processRunOperation(item: AutoBatchQueueItem) {
const oldTimeout = this.autoBatchTimeout;
clearTimeout(this.autoBatchTimeout);
this.autoBatchTimeout = undefined;
if (item.action === "create") {
Expand All @@ -814,15 +811,10 @@ export class Client {
this.drainAutoBatchQueue(sizeLimitBytes);
}
if (this.autoBatchQueue.items.length > 0) {
this.autoBatchTimeout = setTimeout(
() => {
this.autoBatchTimeout = undefined;
this.drainAutoBatchQueue(sizeLimitBytes);
},
oldTimeout
? this.autoBatchAggregationDelayMs
: this.autoBatchInitialDelayMs
);
this.autoBatchTimeout = setTimeout(() => {
this.autoBatchTimeout = undefined;
this.drainAutoBatchQueue(sizeLimitBytes);
}, this.autoBatchAggregationDelayMs);
}
return itemPromise;
}
Expand Down
4 changes: 2 additions & 2 deletions js/src/tests/traceable.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ test.concurrent(
{
test1bin: ["application/octet-stream", testAttachment1],
test2bin: ["application/octet-stream", testAttachment2],
"input.bin": ["application/octet-stream", attachment],
"input2.bin": [
inputbin: ["application/octet-stream", attachment],
input2bin: [
"application/octet-stream",
new Uint8Array(attachment2),
],
Expand Down

0 comments on commit a8cab88

Please sign in to comment.