Files
ChatLab/apps/desktop/main/network/proxy-apply-queue.ts
T
digua cbc8728f41 fix(electron): resolve model download proxy from session
Make desktop proxy saves await Electron session proxy application before model download proxy resolution.

Resolve HTTP, HTTPS, and SOCKS system proxy rules for semantic index model downloads while preserving DIRECT precedence.
2026-06-26 09:56:32 +08:00

22 lines
563 B
TypeScript

export class ProxyApplyQueue {
private pendingApply: Promise<unknown> | null = null
apply<T>(task: () => Promise<T>): Promise<T> {
const previous = this.pendingApply ?? Promise.resolve()
const current = previous.catch(() => undefined).then(task)
this.pendingApply = current
const clear = () => {
if (this.pendingApply === current) this.pendingApply = null
}
current.then(clear, clear)
return current
}
async waitForPending(): Promise<void> {
const pending = this.pendingApply
if (pending) await pending
}
}