[PP-1] Ensure asynchronous tasks that run beyond the length of a request have the chance to complete before process exit

Created on 3 March 2024, 4 months ago

Problem/Motivation

With πŸ“Œ Add revoltphp/event-loop dependency to core Active we enable core and contrib developers to easily kick-off asynchronous tasks. In a lot of use-cases (e.g. BigPipe) where the request code waits for the tasks that were kicked-off to be completed this doesn't matter because the tasks are shorter than the request. However it is also possible to kick-off tasks (e.g. search engine indexing) where the result is not important for the current request.

In the case that the tasks take longer to complete than it takes to send the response for a request and to terminate the kernel, in the current Drupal implementation, the tasks may get discarded as the request process exits.

To demonstrate this and other Revolt related things I've created a Revolt Playground repository on GitHub. For this problem compare the two examples in the Bootstrap demo.

Steps to reproduce

Proposed resolution

Add EventLoop::run() to the end of the index.php file so that async tasks that were started but not yet completed before we get to that line have the opportunity to complete.

This placement is under the assumption that $kernel->terminate($request, $response); does not throw away any data that these asynchronous tasks may need.

Remaining tasks

This is postponed on πŸ“Œ Add revoltphp/event-loop dependency to core Active

  • Agree on the placement of EventLoop::run or optionally provide a way for async tasks to signal they need to complete before $kernel->terminate($request, $response); and provide a synchronisation point in Drupal core
  • Create the merge request
  • Write the release notes

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 38 minutes ago

Created by

πŸ‡³πŸ‡±Netherlands Kingdutch

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

Comments & Activities

Production build 0.69.0 2024