Skip to content

Commit 960b94b

Browse files
authored
chore: bump version to 5.11.4 (#120)
fix: increase TTL test margins to prevent flaky failures on slow CI runners (especially Windows). TTL 200ms->500ms, waits 300ms->700ms, refresh test TTL 300ms->2000ms.
1 parent 0859f80 commit 960b94b

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [5.11.4](https://github.com/SocketDev/socket-lib/releases/tag/v5.11.4) - 2026-03-28
9+
10+
### Changed
11+
12+
- **perf**: Lazy-load heavy external sub-bundles across 7 modules (#119)
13+
- `sorts.ts`: Defer semver (2.5 MB via npm-pack) and fastSort until first use
14+
- `versions.ts`: Defer semver until first use
15+
- `archives.ts`: Defer adm-zip (102 KB) and tar-fs (105 KB) until extraction
16+
- `globs.ts`: Defer fast-glob and picomatch (260 KB via pico-pack) until glob execution
17+
- `fs.ts`: Defer del (260 KB via pico-pack) until safeDelete call
18+
- `spawn.ts`: Defer @npmcli/promise-spawn (17 KB) until async spawn
19+
- `strings.ts`: Defer get-east-asian-width (10 KB) until stringWidth call
20+
- Importing lightweight exports (isObject, httpJson, localeCompare, readJsonSync, stripAnsi) no longer loads heavy externals at module init time
21+
822
## [5.11.3](https://github.com/SocketDev/socket-lib/releases/tag/v5.11.3) - 2026-03-26
923

1024
### Fixed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@socketsecurity/lib",
3-
"version": "5.11.3",
3+
"version": "5.11.4",
44
"packageManager": "pnpm@10.33.0",
55
"license": "MIT",
66
"description": "Core utilities and infrastructure for Socket.dev security tools",

test/unit/cache-with-ttl.test.mts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,17 @@ describe.sequential('cache-with-ttl', () => {
185185
})
186186

187187
it('should fetch again after cache expires', async () => {
188-
// Use longer TTL (200ms) to avoid flaky failures on slow CI runners.
188+
// Use generous TTL to avoid flaky failures on slow CI runners (especially Windows).
189189
const shortCache = createTtlCache({
190-
ttl: 200,
190+
ttl: 500,
191191
prefix: 'short-cache',
192192
})
193193
const fetcher = vi.fn(async () => 'value')
194194
await shortCache.getOrFetch('key', fetcher)
195195
expect(fetcher).toHaveBeenCalledTimes(1)
196196

197-
// Wait for TTL to expire (300ms > 200ms TTL).
198-
await new Promise(resolve => setTimeout(resolve, 300))
197+
// Wait for TTL to expire (700ms > 500ms TTL).
198+
await new Promise(resolve => setTimeout(resolve, 700))
199199

200200
await shortCache.getOrFetch('key', fetcher)
201201
expect(fetcher).toHaveBeenCalledTimes(2)
@@ -327,17 +327,17 @@ describe.sequential('cache-with-ttl', () => {
327327
})
328328

329329
it('should skip expired entries in getAll', async () => {
330-
// Use longer TTL (200ms) to avoid flaky failures on slow CI runners.
330+
// Use generous TTL to avoid flaky failures on slow CI runners (especially Windows).
331331
const shortCache = createTtlCache({
332-
ttl: 200,
332+
ttl: 500,
333333
prefix: 'expiry-getall-test',
334334
})
335335

336336
await shortCache.set('key1', 'value1')
337337
await shortCache.set('key2', 'value2')
338338

339-
// Wait for TTL to expire (300ms > 200ms TTL).
340-
await new Promise(resolve => setTimeout(resolve, 300))
339+
// Wait for TTL to expire (700ms > 500ms TTL).
340+
await new Promise(resolve => setTimeout(resolve, 700))
341341

342342
const all = await shortCache.getAll<string>('*')
343343
expect(all.size).toBe(0)
@@ -416,18 +416,17 @@ describe.sequential('cache-with-ttl', () => {
416416

417417
describe('TTL expiration', () => {
418418
it('should expire entries after TTL', async () => {
419-
// Use longer TTL (200ms) to avoid flaky failures on slow CI runners.
420-
// Windows in particular can have significant I/O latency during cacache.put().
419+
// Use generous TTL to avoid flaky failures on slow CI runners (especially Windows).
421420
const shortCache = createTtlCache({
422-
ttl: 200,
421+
ttl: 500,
423422
prefix: 'expiry-test',
424423
})
425424

426425
await shortCache.set('key', 'value')
427426
expect(await shortCache.get<string>('key')).toBe('value')
428427

429-
// Wait for TTL to expire (300ms > 200ms TTL).
430-
await new Promise(resolve => setTimeout(resolve, 300))
428+
// Wait for TTL to expire (700ms > 500ms TTL).
429+
await new Promise(resolve => setTimeout(resolve, 700))
431430

432431
expect(await shortCache.get('key')).toBeUndefined()
433432

@@ -453,16 +452,16 @@ describe.sequential('cache-with-ttl', () => {
453452

454453
it('should refresh TTL on set', async () => {
455454
const refreshCache = createTtlCache({
456-
ttl: 300,
455+
ttl: 2000,
457456
prefix: 'refresh-cache',
458457
})
459458

460459
await refreshCache.set('key', 'value1')
461-
await new Promise(resolve => setTimeout(resolve, 100))
460+
await new Promise(resolve => setTimeout(resolve, 200))
462461
await refreshCache.set('key', 'value2') // Refresh TTL
463462

464-
await new Promise(resolve => setTimeout(resolve, 100))
465-
// Should still be cached (100 + 100 = 200ms, but TTL refreshed at 100ms to 300ms)
463+
await new Promise(resolve => setTimeout(resolve, 200))
464+
// Should still be cached (200 + 200 = 400ms, but TTL refreshed at 200ms to 2000ms)
466465
expect(await refreshCache.get<string>('key')).toBe('value2')
467466

468467
await refreshCache.clear()

0 commit comments

Comments
 (0)