ArgumentCountError: BlockViewBuilder::lazyBuilder() accepts only 2 parameters, but ajax_big_pipe passes 3

Created on 24 July 2025, about 1 month ago

Problem/Motivation

The ajax_big_pipe module incorrectly calls `BlockViewBuilder::lazyBuilder()` with 3 parameters when it only accepts 2, causing an ArgumentCountError when the lazy builder callback is executed.

Drupal 10.5.x
php8.3

In `ajax_big_pipe.module` at line 40-47, the module sets up a lazy builder like this:

$build['#lazy_builder'] = [
  BlockViewBuilder::class . '::lazyBuilder',
  [
    'id' => $entityId,           // Problem 1: Using named array keys
    'mode' => 'full',             // Problem 2: Using named array keys
    'params' => json_encode($visible['ajax_big_pipe_condition']), // Problem 3: Extra parameter
  ],
];

However, the core `BlockViewBuilder::lazyBuilder()` method only accepts 2 parameters:

public static function lazyBuilder($entity_id, $view_mode) {
  return static::buildPreRenderableBlock(Block::load($entity_id), \Drupal::service('module_handler'));
}

Steps to reproduce

1. Install Drupal 10.5.x with ajax_big_pipe module
2. Configure a block to use ajax_big_pipe by enabling "Use Ajax Big Pipe" in the block's visibility settings
3. View a page containing that block
4. When the lazy builder callback executes, you'll get an error:

Proposed resolution

1. Named array keys: The module is passing an associative array with keys 'id', 'mode', 'params' instead of a numeric array
2. Wrong parameter count: Passing 3 parameters when the method only accepts 2
3. Unused implementation: The module has its own `LazyBlockBuilder::lazyBlockBuild()` method but it's just a stub that returns markup instead of rendering the block

The module appears to have started implementing its own lazy builder infrastructure, falling back to incorrectly using core's BlockViewBuilder.

Option 1: Fix the parameters
Option 2: Complete the LazyBlockBuilder implementation
Option 3: Use a different approach:

Since the module is trying to implement BigPipe functionality for blocks, consider using Drupal's built-in BigPipe module patterns instead of custom lazy builders.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States SocialNicheGuru

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024