mirror of
https://github.com/alrayyes/wiki.git
synced 2025-05-01 06:28:14 +00:00
fix: add async-mutex to builds on large vaults
This commit is contained in:
parent
b99d4cd8ce
commit
e65ea48fae
5 changed files with 29 additions and 6 deletions
quartz
|
@ -16,6 +16,7 @@ import http from "http"
|
|||
import serveHandler from "serve-handler"
|
||||
import { WebSocketServer } from "ws"
|
||||
import { randomUUID } from "crypto"
|
||||
import { Mutex } from "async-mutex"
|
||||
|
||||
const ORIGIN_NAME = "origin"
|
||||
const UPSTREAM_NAME = "upstream"
|
||||
|
@ -391,8 +392,10 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
|
|||
],
|
||||
})
|
||||
|
||||
const buildMutex = new Mutex()
|
||||
const timeoutIds = new Set()
|
||||
const build = async (clientRefresh) => {
|
||||
await buildMutex.acquire()
|
||||
const result = await ctx.rebuild().catch((err) => {
|
||||
console.error(`${chalk.red("Couldn't parse Quartz configuration:")} ${fp}`)
|
||||
console.log(`Reason: ${chalk.grey(err)}`)
|
||||
|
@ -415,6 +418,7 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
|
|||
const { default: buildQuartz } = await import(cacheFile + `?update=${randomUUID()}`)
|
||||
await buildQuartz(argv, clientRefresh)
|
||||
clientRefresh()
|
||||
buildMutex.release()
|
||||
}
|
||||
|
||||
const rebuild = (clientRefresh) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue