Skip to content

Commit

Permalink
improve: subtree resolver batch handling (via #5193)
Browse files Browse the repository at this point in the history
* fix: prevent subtree paths from being queued more than once in a batch

* fix: clear subtree resolver errors by current path

* drop `List` import
  • Loading branch information
shockey authored Feb 25, 2019
1 parent 080c70a commit 0990aa8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/core/plugins/spec/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,11 @@ const debResolveSubtrees = debounce(async () => {
})

if(errSelectors.allErrors().size) {
errActions.clear({
type: "thrown"
errActions.clearBy(err => {
// keep if...
return err.get("type") !== "thrown" // it's not a thrown error
|| err.get("source") !== "resolver" // it's not a resolver error
|| !err.get("fullPath").every((key, i) => key === path[i] || path[i] === undefined) // it's not within the path we're resolving
})
}

Expand Down Expand Up @@ -225,6 +228,16 @@ const debResolveSubtrees = debounce(async () => {
}, 35)

export const requestResolvedSubtree = path => system => {
// poor-man's array comparison
// if this ever inadequate, this should be rewritten to use Im.List
const isPathAlreadyBatched = requestBatch
.map(arr => arr.join("@@"))
.indexOf(path.join("@@")) > -1

if(isPathAlreadyBatched) {
return
}

requestBatch.push(path)
requestBatch.system = system
debResolveSubtrees()
Expand Down

0 comments on commit 0990aa8

Please sign in to comment.