//#region src/lib/server/serial-queue.ts
/**
* Per-process serial queues, keyed by caller-chosen string.
*
* Two concurrent calls with the same key run sequentially (the second
* awaits the first). Different keys are independent. Failures don't
* poison the chain — the next caller gets a fresh promise.
*
* Use for admin routes that run docker compose work (compose up / pull /
* restart). Concurrent --force-recreate invocations against the same
* project kill each other's containers mid-healthcheck; the queue
* prevents that.
*/
var queues = /* @__PURE__ */ new Map();
function withSerialQueue(key, run) {
	const next = (queues.get(key) ?? Promise.resolve()).then(run, run);
	queues.set(key, next.catch(() => void 0));
	return next;
}

export { withSerialQueue as w };
//# sourceMappingURL=serial-queue-D9FEpYVv.js.map
