MCPcopy Create free account
hub / github.com/Effect-TS/effect / settleRunEntry

Function settleRunEntry

packages/effect/src/ui/Query.ts:6673–6724  ·  view source on GitHub ↗
(entry: Entry)

Source from the content-addressed store, hash-verified

6671 // -- runs, patches and writes -----------------------------------------------
6672 /** The check made when a run's patches stop being live on an entry: a refetch that was held back. */
6673 const settleRunEntry = (entry: Entry): void => {
6674 if (entry.removed) return
6675 if (!hasLive(entry)) {
6676 // A caller-only fetch in flight finishes for its callers. Later `get`s don't join it.
6677 entry.shared = undefined
6678 const deferred = entry.deferred
6679 const deferredParent = entry.deferredParent
6680 const deferredWatcher = entry.deferredWatcher
6681 entry.deferred = undefined
6682 entry.deferredParent = undefined
6683 entry.deferredWatcher = undefined
6684 // An invalidation held back by the patch closes an open stream now, watched or not.
6685 if (deferred !== undefined && entry.live !== undefined) dropFetch(entry)
6686 // `get`s that joined a reconnecting stream wait for its successor.
6687 if (entry.fetch === undefined && (entry.watchers.size > 0 || entry.waiters.size > 0)) {
6688 if (isStale(entry) || (intervalElapsed(entry) && !paused())) {
6689 const build = survivingBuild(entry)
6690 if (build !== undefined) {
6691 ensureFetch(
6692 entry,
6693 deferred ?? "invalidation",
6694 build,
6695 deferredParent,
6696 // Without a deferred trigger, this watcher belongs to a window-held loadMore.
6697 deferred === undefined ? undefined : deferredWatcher
6698 )
6699 }
6700 } else if (
6701 entry.intervalDue !== undefined &&
6702 entry.intervalCancel === undefined && !paused()
6703 ) {
6704 armInterval(entry)
6705 }
6706 }
6707 if (entry.def.list !== undefined && entry.fetch === undefined) {
6708 entry.def.list.ops.heldLoadMore(
6709 cacheEnv(),
6710 entry,
6711 deferred ?? "loadMore",
6712 deferredParent,
6713 deferredWatcher
6714 )
6715 }
6716 // A dropped walk nothing restarted isn't owed a restart by a later fetch, and a prefetch's claim is spent.
6717 if (entry.fetch === undefined) {
6718 entry.heldRestart = false
6719 entry.kept = false
6720 }
6721 }
6722 emit(entry)
6723 afterQuiet(entry)
6724 }
6725 /** `Equal.equals`, true when it throws: a check that only reports never fails a run. */
6726 const equalsOrTrue = (a: unknown, b: unknown): boolean => {
6727 try {

Callers 1

beginRunFunction · 0.85

Calls 11

hasLiveFunction · 0.85
dropFetchFunction · 0.85
intervalElapsedFunction · 0.85
pausedFunction · 0.85
survivingBuildFunction · 0.85
ensureFetchFunction · 0.85
armIntervalFunction · 0.85
cacheEnvFunction · 0.85
afterQuietFunction · 0.85
isStaleFunction · 0.70
emitFunction · 0.70

Tested by

no test coverage detected