Skip to content

fix(gsheets-logger): clamp flush interval/batch size to safe positives (v0.2.2) - #2

Merged
rmyndharis merged 1 commit into
mainfrom
gsheets-logger-config-clamp
Jun 23, 2026
Merged

fix(gsheets-logger): clamp flush interval/batch size to safe positives (v0.2.2)#2
rmyndharis merged 1 commit into
mainfrom
gsheets-logger-config-clamp

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

Summary

Hardens gsheets-logger config parsing, released as v0.2.2.

flushIntervalSec and flushBatchSize were passed straight through Number(...). A non-numeric value (e.g. a stray string) coerces to NaN:

  • setInterval(fn, NaN * 1000) is treated as setInterval(fn, 0) → the flush timer fires roughly every millisecond, a hot-loop that burns CPU and exhausts the Google Sheets API quota.
  • A NaN batch size makes buffer.length >= NaN always false, silently disabling the size-based flush trigger.

Both values are now validated in parseConfig: non-finite or non-positive inputs fall back to the documented defaults (5s interval, 20-row batch). Valid values pass through unchanged.

Tests

  • New: non-numeric / zero / negative interval and batch size clamp to defaults; valid values pass through.
  • Full suite green, tsc --noEmit clean, bundle packages cleanly.

…s (v0.2.2)

A non-numeric or zero/negative flushIntervalSec coerced to NaN, and setInterval(NaN)
fires at ~1ms — a flush hot-loop that burns CPU and Sheets API quota. A NaN batch
size silently disabled the size trigger. Both are now validated in parseConfig and
fall back to the documented defaults (5s / 20 rows).
@rmyndharis
rmyndharis merged commit bf1cbf9 into main Jun 23, 2026
1 check passed
@rmyndharis
rmyndharis deleted the gsheets-logger-config-clamp branch June 23, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant