Commit 522d1f4
fix(logging): scope logRotator state per instance
`lastRotationTime` and `setIntervalId` were module-level. After #1111
fixed the broken require so harper_logger.getFileLogger actually
creates rotators, multiple rotators can exist concurrently (e.g. for
http logger, external logger, hdb logger). Every new rotator call
overwrites the shared `setIntervalId`, so `rotator.end()` on any
instance clears the most-recently-created interval — not its own.
This surfaced as a unit-test regression: the harper_logger HTTP and
global-logger tests trigger lingering setTimeouts (from the
`path =` setter calling getFileLogger) that fire ~100ms later. When
the logRotator test then created its rotator, the lingering
setTimeouts called `logger.rotator?.end()` -> `clearInterval(module-level setIntervalId)`,
which clobbered the test's interval. The rotation never fired and
`getLastRotatedLogPath()` returned undefined.
Move both variables into the function closure so each rotator owns
its own state and `end()` only clears its own interval.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent bce7e4d commit 522d1f4
1 file changed
Lines changed: 2 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 21 | | |
25 | 22 | | |
26 | 23 | | |
| |||
67 | 64 | | |
68 | 65 | | |
69 | 66 | | |
70 | | - | |
| 67 | + | |
71 | 68 | | |
72 | | - | |
| 69 | + | |
73 | 70 | | |
74 | 71 | | |
75 | 72 | | |
| |||
0 commit comments