@rabbit-company/logger 5.6.0 → 5.6.1

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.
Files changed (2) hide show
  1. package/module/logger.js +14 -7
  2. package/package.json +3 -3
package/module/logger.js CHANGED
@@ -311,19 +311,26 @@ class LokiTransport {
311
311
  scheduleSend(immediate = false) {
312
312
  if (this.isSending)
313
313
  return;
314
- if (this.timeoutHandle) {
315
- clearTimeout(this.timeoutHandle);
316
- this.timeoutHandle = undefined;
317
- }
318
- if (this.queue.length > 0 && (immediate || this.queue.length >= this.batchSize)) {
314
+ if (immediate || this.queue.length >= this.batchSize) {
315
+ if (this.timeoutHandle) {
316
+ clearTimeout(this.timeoutHandle);
317
+ this.timeoutHandle = undefined;
318
+ }
319
319
  this.sendBatch();
320
- } else if (this.queue.length > 0) {
321
- this.timeoutHandle = setTimeout(() => this.sendBatch(), this.batchTimeout);
320
+ } else if (this.queue.length > 0 && !this.timeoutHandle) {
321
+ this.timeoutHandle = setTimeout(() => {
322
+ this.timeoutHandle = undefined;
323
+ this.sendBatch();
324
+ }, this.batchTimeout);
322
325
  }
323
326
  }
324
327
  async sendBatch() {
325
328
  if (this.queue.length === 0 || this.isSending)
326
329
  return;
330
+ if (this.timeoutHandle) {
331
+ clearTimeout(this.timeoutHandle);
332
+ this.timeoutHandle = undefined;
333
+ }
327
334
  this.isSending = true;
328
335
  const batchToSend = this.queue.slice(0, this.batchSize);
329
336
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabbit-company/logger",
3
- "version": "5.6.0",
3
+ "version": "5.6.1",
4
4
  "description": "A simple and lightweight logger",
5
5
  "main": "./module/logger.js",
6
6
  "type": "module",
@@ -36,9 +36,9 @@
36
36
  ],
37
37
  "devDependencies": {
38
38
  "@types/bun": "latest",
39
- "bun-plugin-dts": "^0.3.0"
39
+ "bun-plugin-dts": "^0.4.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "typescript": "^5.8.3"
42
+ "typescript": "^5.9.3"
43
43
  }
44
44
  }