Skip to content

Commit

Permalink
fix(cli): fix call stack exceed error
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 29, 2021
1 parent c5a0124 commit 4569000
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/koishi/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,15 @@ function createWatcher() {
* - file X -> none of change D
*/
const declined = new Set(externals)
const visited = new Set<string>()

function traverse(filename: string) {
if (externals.has(filename) || filename.includes('/node_modules/')) return
if (declined.has(filename) || filename.includes('/node_modules/')) return
visited.add(filename)
const { children } = require.cache[filename]
let isActive = stashed.has(filename)
for (const module of children) {
if (visited.has(filename)) continue
if (traverse(module.filename)) {
stashed.add(filename)
isActive = true
Expand Down

0 comments on commit 4569000

Please sign in to comment.