Skip to content

Commit

Permalink
core: add some more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed Oct 7, 2024
1 parent a47ca71 commit dcf0a12
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export function sequentializeListenerEvents(options?: {
}

if (
nextBuffer.length >= ((window as any).__sanity_debug_maxBufferSize ?? maxBufferSize)
nextBuffer.length >=
((globalThis as any).__sanity_debug_maxBufferSize ?? maxBufferSize)
) {
throw new MaxBufferExceededError(
`Too many unchainable mutation events: ${state.buffer.length}`,
Expand All @@ -128,10 +129,18 @@ export function sequentializeListenerEvents(options?: {
},
),
switchMap((state) => {
const deadline =
(globalThis as any).__sanity_debug_resolveChainDeadline ?? resolveChainDeadline

if (state.buffer.length > 0) {
debug(
"Detected %d listener event(s) that can't be applied in sequence. This could be due to events arriving out of order. Will throw an error if chain can't be resolved within %dms",
state.buffer.length,
deadline,
)
return concat(
of(state),
timer((window as any).__sanity_debug_resolveChainDeadline ?? resolveChainDeadline).pipe(
timer(deadline).pipe(
mergeMap(() =>
throwError(() => {
return new DeadlineExceededError(
Expand Down

0 comments on commit dcf0a12

Please sign in to comment.