Skip to content

Commit f751caf

Browse files
authored
Merge pull request #1638 from akim-bow/unref-sucrose-gc-timeout
fix: add unref to sucrose gc timeout
2 parents 00ea802 + c984518 commit f751caf

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/sucrose.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ export const isContextPassToFunction = (
617617
}
618618
}
619619

620-
let pendingGC: number | undefined
620+
let pendingGC: Timer | undefined
621621
let caches = <Record<number, Sucrose.Inference>>{}
622622

623623
export const clearSucroseCache = (delay: Sucrose.Settings['gcTime']) => {
@@ -632,7 +632,7 @@ export const clearSucroseCache = (delay: Sucrose.Settings['gcTime']) => {
632632

633633
pendingGC = undefined
634634
if (isBun) Bun.gc(false)
635-
}, delay) as unknown as number
635+
}, delay).unref()
636636
}
637637

638638
export const mergeInference = (a: Sucrose.Inference, b: Sucrose.Inference) => {

test/sucrose/integration.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { describe, expect, it } from 'bun:test'
2+
3+
describe('Integration', () => {
4+
it(
5+
'Allows process to finish',
6+
async () => {
7+
const res = Bun.spawn({
8+
cmd: [
9+
'bun',
10+
'-e',
11+
"import { Elysia } from './src'; new Elysia().onBeforeHandle(() => { });"
12+
]
13+
})
14+
15+
const status = await res.exited;
16+
expect(status).toEqual(0);
17+
},
18+
{
19+
timeout: 500
20+
}
21+
)
22+
})

0 commit comments

Comments
 (0)