Commit f9b741e
Fix garbage collection issue with Infinity setting (#1135)
* fix(db): handle gcTime Infinity to prevent immediate garbage collection
When gcTime was set to Infinity, setTimeout(fn, Infinity) would coerce
Infinity to 0 via JavaScript's ToInt32 conversion, causing immediate
garbage collection instead of disabling it.
This fix treats Infinity (and any non-finite values) the same as 0,
effectively disabling automatic garbage collection when the user intends
for data to never be collected.
Fixes issue where collections in Electron apps would unexpectedly lose
data when navigating back and forth with gcTime set to Infinity.
* chore: add changeset for gcTime Infinity fix
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* Handle negative gcTime values in GC timer
Negative gcTime values like -1000 would pass through to setTimeout,
which browsers treat as 0 (immediate execution). Now gcTime <= 0
disables GC, matching the intent of invalid timeout values.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
---------
Co-authored-by: Claude <[email protected]>1 parent 9204d76 commit f9b741e
3 files changed
Lines changed: 29 additions & 2 deletions
File tree
- .changeset
- packages/db
- src/collection
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
184 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
185 | 187 | | |
186 | 188 | | |
187 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
363 | 383 | | |
364 | 384 | | |
365 | 385 | | |
| |||
0 commit comments