Skip to content

Allow suspending sequential revalidations if network request fails #695

Open
@mglaman

Description

@mglaman

Package

next (Drupal module)

Describe the feature request

If there is an issue making a network request from Drupal to the Next.js site, additional failing requests can be sent out that wil also fail and add additional logs/processing time.

Describe the solution you'd like

If the first revalidation hits a network error or server error, halt sending any further validations.

Something like private readonly bool $halt = false in EntityActionEventRevalidateSubscriber and:

    if (!$this->halt && $revalidator = $this->nextEntityTypeManager->getRevalidator($event->getEntity())) {
      try {
        $revalidated = $revalidator->revalidate($event);
        // Dispatch post revalidation event.
        $revalidated_event = EntityRevalidatedEvent::createFromEntityActionEvent($event);
        $revalidated_event->setRevalidated($revalidated);
        $this->eventDispatcher->dispatch($revalidated_event, EntityEvents::ENTITY_REVALIDATED);
      catch (Exception) {
          $this->halt = true;
      }     
    }

If #445 this would be like re-queueing the existing item and suspending the queue.

Describe alternatives you've considered

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions