Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear ActionContext in BackgroundJob #14031

Merged
merged 1 commit into from
Aug 1, 2023
Merged

Conversation

jtkech
Copy link
Member

@jtkech jtkech commented Jul 25, 2023

Fixes #14032

Related to the #14025 discussion

In a background job (not a background task) executed after the end of a request, we need to also clear the IActionContextAccessor.ActionContext because this AsyncLocal field is not cleared by AspnetCore and still references the previous HttpContext.

So, clearing this field prevents this stale ActionContext to be used. In the related issue it is used in a background job that calls ILiquidTemplateManager.RenderStringAsync().

@jtkech jtkech merged commit 0937df9 into main Aug 1, 2023
@jtkech jtkech deleted the jtkech/clear-action-context branch August 1, 2023 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The HttpBackgroundJob can't excute liquid render
1 participant