Skip to content

Unbounded recursion in minusWherePredicates / isWhereSubsetInternal overflows the stack under rapid on-demand subset churn #1591

@simonstaffgenius

Description

@simonstaffgenius
  • I've validated the bug against the latest version of DB packages

Describe the bug
Rapidly fetching on-demand subsets (e.g. while scrolling a virtualized view that re-windows on every scroll) throws RangeError: Maximum call stack size exceeded. The stack points into query/predicate-utils.jsminusWherePredicates and isWhereSubsetInternal, which are mutually recursive and have no depth bound.

To Reproduce
Steps to reproduce the behavior:

  • Trigger is rapid window churn against an on-demand collection whose subset where carries an IN/= ANY clause.
  • A Node harness importing the real DeduplicatedLoadSubset reproduces the predicate accumulation, but the overflow needs the join-derived IN clause plus realistic async live-query timing to manifest.

Suggested fix

A depth guard on the mutually recursive walkers that bails conservatively (minusnull, isWhereSubsetfalse) so a too-deep case just costs a redundant re-request rather than crashing. Better still would be flattening the inor handling so the subtraction doesn't recurse per disjunct.

Desktop:

  • OS: macOS 26 Tahoe
  • Browser chrome, safari, firefox
  • Version 0.6.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions