reduce task leaking (#2868)

* reduce task leaking

* fix onLeaveContext
This commit is contained in:
Aiden McClelland
2025-04-16 11:00:46 -06:00
committed by GitHub
parent 03f8b73627
commit 89f3fdc05f
18 changed files with 159 additions and 98 deletions

View File

@@ -113,7 +113,12 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {
| "bind"
| "getHostInfo"
type MainUsedEffects = "setMainStatus" | "setHealth"
type CallbackEffects = "constRetry" | "clearCallbacks"
type CallbackEffects =
| "child"
| "constRetry"
| "isInContext"
| "onLeaveContext"
| "clearCallbacks"
type AlreadyExposed =
| "getSslCertificate"
| "getSystemSmtp"
@@ -211,10 +216,15 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {
> = {},
) => {
async function* watch() {
while (true) {
const resolveCell = { resolve: () => {} }
effects.onLeaveContext(() => {
resolveCell.resolve()
})
while (effects.isInContext) {
let callback: () => void = () => {}
const waitForNext = new Promise<void>((resolve) => {
callback = resolve
resolveCell.resolve = resolve
})
yield await effects.getContainerIp({ ...options, callback })
await waitForNext