Skip to content

Defer tasks until after response is sent #15622

Closed Answered by brandonkelly
bencroker asked this question in Ideas
Discussion options

You must be logged in to vote

Tricking PHP into continuing to execute after the response has been sent is pretty hacky. Craft makes it possible via craft\web\Response::sendAndClose(), and we call it on queue runner requests before processing the queue. But it’s not something we would want to do automatically on every single request, just in case something has registered an ON_AFTER_RESPONSE event handler.

But you’re free to call that sendAndClose() method yourself in cases where you need to do post-response work!

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@brandonkelly
Comment options

@bencroker
Comment options

@bencroker
Comment options

Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants