{"record":{"id":"40a09176eb6f4b93","repo":"angular/components","slug":"cdk-virtual-scroll-maxbufferpx-must-be-greater-th","errorCode":null,"errorMessage":"CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx","messagePattern":"CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts","lineNumber":186,"sourceCode":"  scrollToIndex(): void {\n    if (typeof ngDevMode === 'undefined' || ngDevMode) {\n      // TODO(mmalerba): Implement.\n      throw Error(\n        'cdk-virtual-scroll: scrollToIndex is currently not supported for the autosize' +\n          ' scroll strategy',\n      );\n    }\n  }\n\n  /**\n   * Update the buffer parameters.\n   * @param minBufferPx The minimum amount of buffer rendered beyond the viewport (in pixels).\n   * @param maxBufferPx The number of buffer items to render beyond the edge of the viewport (in\n   *     pixels).\n   */\n  updateBufferSize(minBufferPx: number, maxBufferPx: number) {\n    if (maxBufferPx < minBufferPx) {\n      throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');\n    }\n    this._minBufferPx = minBufferPx;\n    this._maxBufferPx = maxBufferPx;\n  }\n\n  /** Update the rendered content after the user scrolls. */\n  private _updateRenderedContentAfterScroll() {\n    const viewport = this._viewport!;\n\n    // The current scroll offset.\n    const scrollOffset = viewport.measureScrollOffset();\n    // The delta between the current scroll offset and the previously recorded scroll offset.\n    let scrollDelta = scrollOffset - this._lastScrollOffset;\n    // The magnitude of the scroll delta.\n    let scrollMagnitude = Math.abs(scrollDelta);\n\n    // The currently rendered range.\n    const renderedRange = viewport.getRenderedRange();","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts#L168-L204","documentation":"AutoSizeVirtualScrollStrategy.updateBufferSize validates that maxBufferPx (extra rendered content beyond the viewport) is greater than or equal to minBufferPx (the minimum rendered buffer before new items are fetched). Passing a max smaller than min would produce contradictory buffering behavior, so it throws immediately. Note the arguments are (minBufferPx, maxBufferPx) in that order.","triggerScenarios":"Calling updateBufferSize(min, max) — or binding the cdkVirtualScrollMinBufferPx/cdkVirtualScrollMaxBufferPx inputs to values where maxBufferPx < minBufferPx — on a viewport using the autosize strategy.","commonSituations":"Swapped input values (max bound before min by mistake); computing buffer sizes dynamically and getting an inverted pair; copying config between strategies with different parameter order.","solutions":["Ensure maxBufferPx >= minBufferPx: e.g. updateBufferSize(100, 200).","Swap the arguments if you accidentally passed them in reverse order.","Add a guard where buffers are computed: const min = x, max = Math.max(x, y) before calling updateBufferSize."],"exampleFix":"// before\nstrategy.updateBufferSize(500, 200); // max < min -> throws\n// after\nstrategy.updateBufferSize(200, 500);","handlingStrategy":"validation","validationCode":"function safeUpdateBufferSize(s: AutoSizeVirtualScrollStrategy, min: number, max: number) {\n  if (min < 0 || max < min) throw new RangeError('maxBufferPx must be >= minBufferPx');\n  s.updateBufferSize(min, max);\n}","typeGuard":null,"tryCatchPattern":"try {\n  strategy.updateBufferSize(minBufferPx, maxBufferPx);\n} catch (e) {\n  strategy.updateBufferSize(minBufferPx, Math.max(minBufferPx, maxBufferPx));\n}","preventionTips":["Remember the signature order: updateBufferSize(minBufferPx, maxBufferPx).","Normalize computed buffers: max = Math.max(min, max) before calling.","Add unit tests around buffer configuration values."],"tags":["angular","cdk","virtual-scroll","validation","arguments"],"backgroundTag":"invalid-argument-range","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}