From 7aad74733a0a6968c0dc0fb8dba4ebd98ca63f78 Mon Sep 17 00:00:00 2001 From: Akim Mamedov Date: Sat, 27 Dec 2025 21:35:08 +0700 Subject: [PATCH 1/4] fix: add unref to sucrose.ts gc timeout --- src/sucrose.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sucrose.ts b/src/sucrose.ts index 1bc2d851..5caa5ca5 100644 --- a/src/sucrose.ts +++ b/src/sucrose.ts @@ -617,7 +617,7 @@ export const isContextPassToFunction = ( } } -let pendingGC: number | undefined +let pendingGC: Timer | undefined let caches = >{} export const clearSucroseCache = (delay: Sucrose.Settings['gcTime']) => { @@ -632,7 +632,7 @@ export const clearSucroseCache = (delay: Sucrose.Settings['gcTime']) => { pendingGC = undefined if (isBun) Bun.gc(false) - }, delay) as unknown as number + }, delay).unref() } export const mergeInference = (a: Sucrose.Inference, b: Sucrose.Inference) => { From 1004ce8c22a5fcf173d34dfe06d7cbe4b36d1b7b Mon Sep 17 00:00:00 2001 From: Akim Mamedov Date: Sat, 27 Dec 2025 22:01:15 +0700 Subject: [PATCH 2/4] add test for sucrose GC manager --- test/sucrose/integration.test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/sucrose/integration.test.ts diff --git a/test/sucrose/integration.test.ts b/test/sucrose/integration.test.ts new file mode 100644 index 00000000..3d53c8b1 --- /dev/null +++ b/test/sucrose/integration.test.ts @@ -0,0 +1,21 @@ +import { describe, it } from 'bun:test' + +describe('Integration', () => { + it( + 'Allows process to finish', + async () => { + const res = Bun.spawn({ + cmd: [ + 'bun', + '-e', + "import { Elysia } from './src'; new Elysia().onBeforeHandle(() => { });" + ] + }) + + await res.exited + }, + { + timeout: 100 + } + ) +}) From fd9178477595115174b8836b8c7db193e0261909 Mon Sep 17 00:00:00 2001 From: Akim Mamedov Date: Sat, 27 Dec 2025 22:03:38 +0700 Subject: [PATCH 3/4] increate timeout --- test/sucrose/integration.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sucrose/integration.test.ts b/test/sucrose/integration.test.ts index 3d53c8b1..b6662d13 100644 --- a/test/sucrose/integration.test.ts +++ b/test/sucrose/integration.test.ts @@ -15,7 +15,7 @@ describe('Integration', () => { await res.exited }, { - timeout: 100 + timeout: 500 } ) }) From c984518f27b5671c3400c17956d65e3569f183fe Mon Sep 17 00:00:00 2001 From: Akim Mamedov Date: Sat, 27 Dec 2025 22:04:54 +0700 Subject: [PATCH 4/4] check process status --- test/sucrose/integration.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/sucrose/integration.test.ts b/test/sucrose/integration.test.ts index b6662d13..1116628a 100644 --- a/test/sucrose/integration.test.ts +++ b/test/sucrose/integration.test.ts @@ -1,4 +1,4 @@ -import { describe, it } from 'bun:test' +import { describe, expect, it } from 'bun:test' describe('Integration', () => { it( @@ -12,7 +12,8 @@ describe('Integration', () => { ] }) - await res.exited + const status = await res.exited; + expect(status).toEqual(0); }, { timeout: 500