Skip to content

Commit

Permalink
fix: prevent collecting loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Oct 17, 2022
1 parent 0786a57 commit ad6c652
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/histoire/src/node/server.ts
Expand Up @@ -65,6 +65,7 @@ export async function createServer (ctx: Context, options: CreateServerOptions =
// onStoryChange debouncing
let queued = false
let queuedFiles: ServerStoryFile[] = []
let currentFiles: ServerStoryFile[] = []
let queueTimer
let collecting = false
let didAllStoriesYet = false
Expand Down Expand Up @@ -112,6 +113,9 @@ export async function createServer (ctx: Context, options: CreateServerOptions =
clearTimeout(queueTimer)
// Debounce
queueTimer = setTimeout(collect, 100)
} else if (!changedFile && !currentFiles.length) {
// Full collect in progress
queued = false
}
}
})
Expand All @@ -121,7 +125,7 @@ export async function createServer (ctx: Context, options: CreateServerOptions =

clearCache()

const currentFiles = queuedFiles.slice()
currentFiles = queuedFiles.slice()
queuedFiles = []
queued = false

Expand Down

0 comments on commit ad6c652

Please sign in to comment.