Skip to content

[3.8.0+] Django "active" language is not safe to use with ASGI #475

Open
@sshishov

Description

@sshishov

I can reproduce this issue with version 3.8.0 and above.

Create django project with 1 view which will return you active user language:

from django.utils import translation

def view(request):
    return translation.get_language()

Start django under ASGI (using daphne for instance)

Then in 2 terminals/terminal-tabs start the CURL operation for this enpoint with different language in cookies:

while true; do curl ...; done;

And you will observer that every request is affecting the response on another terminal/terminal-tab.

It will be like this:

language: X
langauge: Y
language: X

Meaning it is not consistent when it should be. Especially we are interested in Content-Language header which is set automatically and for us the value of this header is affected by other requests...

NOTE: Downgrading asgiref to version below mentioned (for instance 3.7.2 fixes the issue.

Possibly related: #473

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions