Skip to content

Mojolicious 9.54: premature connection close of the user agent, finish of the daemon, the method of the environment, and streamed responses of Pyjo.App.WSGI - #616

Merged
dex4er merged 3 commits into
mainfrom
mojolicious-9.54
Nov 12, 2026
Merged

dex4er merged 3 commits into
mainfrom
mojolicious-9.54

Conversation

@dex4er

@dex4er dex4er commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

The synchronization with Mojolicious 9.54, of v9.53..v9.54, and two defects of Pyjo.App.WSGI that its stricter user agent showed.

Mojolicious 9.54

  • Pyjo.UserAgent (e6d5a54f0), which came after the list of the issue: a response that is not complete when its connection closes is a premature connection close also after its start-line, unless its body is delimited by the close of the connection, as RFC 9112 says, or the user agent closes it itself in _cleanup, and the finish events of the transaction and of the response see the error.
  • Pyjo.Server.Daemon (60624d154): the cleanup of the server with active connections removes them with _remove, which emits the finish events of their transactions.
  • Pyjo.Message.Request (8b0dbdf72): a method of the environment that is defined, also an empty one; a method and a query of "0" are true in Python already, so only the empty method changes, with a test of its own, as Mojolicious has none.
  • The three modules name Mojolicious 9.54. The subtests of t/mojo/user_agent.t and t/mojo/daemon.t are ported one for one, and fail without the change.

Pyjo.App.WSGI

The user agent accepted a streamed response whose connection closed before its last chunk; two defects ended them so:

  • The call of the application, its iteration and its close run in one context of contextvars, as on a WSGI server, where the callbacks of the event loop of asyncio each run in a context of their own: the iterator of stream_with_context of Flask resets its context variables at its end with the tokens of its start, which raised ValueError, so that a streamed response of Flask closed its connection before its last chunk. t/servers/Mount.py showed it, and t/Pyjo/App_WSGI.py has a test of it without Flask.
  • The steps of a streamed response run on the event loop of its connection, which is the singleton, or one of its own, as of the server of a blocking request of a user agent, where a step of the singleton, which waits for the blocking request, never came. t/Pyjo/App_WSGI.py showed it on Pyjo.Reactor.Poll.

Pyjo.App.CGI, Pyjo.App.FastCGI and Pyjo.App.ASGI schedule on the singleton too; no test shows it under the server of a blocking request, so they stay as they are.

Validation

  • The suite on asyncio and on Pyjo.Reactor.Poll with PYTHONDEVMODE=1, without a ResourceWarning or an unhandled rejected promise
  • t/servers on Python 3.15 and 3.12
  • The changed tests on the reactors of Uvloop, gevent, Twisted and Trio
  • Sphinx with -W, trunk check

Closes #408

🤖 Generated with Claude Code

dex4er and others added 3 commits November 12, 2026 18:01
…se in one context of contextvars

A WSGI server gives them one thread, where the callbacks of the event loop of
asyncio each run in a context of their own: the iterator of
stream_with_context of Flask resets its context variables at its end with
the tokens of its start, which raised ValueError in another context, so that
the connection of a streamed response closed before its last chunk, which
the user agent took for the end of the response until Mojolicious 9.54.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its connection

The event loop of the server that runs the application, which is the
singleton, or one of its own, as of the server of a blocking request of a
user agent, where a step on the singleton, which waits for the blocking
request, never came, so that the response ended without its last chunk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 9.54

- Pyjo.UserAgent: a response that is not complete when its connection
  closes is a premature connection close, also after its start-line, unless
  its body is delimited by the close of the connection, as RFC 9112 says, or
  the user agent closes it itself, and the finish events see the error
  (e6d5a54f0).
- Pyjo.Server.Daemon: the cleanup of the server with active connections
  emits the finish events of their transactions (60624d154).
- Pyjo.Message.Request: a method of the environment that is defined, also an
  empty one, as a method and a query of "0" are true in Python already
  (8b0dbdf72).

Part of #408

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dex4er dex4er added this to the 0.4.0 milestone Nov 12, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 Pyjoyment | 🛠️ Build #35845461 | 📁 Comparing d345179 against latest (e1842db)

  🔍 Preview build  

3 files changed
± api/Pyjo_Message_Request.html
± api/Pyjo_Server_Daemon.html
± api/Pyjo_UserAgent.html

@github-actions

Copy link
Copy Markdown
Contributor

Docker Smoke Test

Job Tests Passed ✅ Skipped ⚠️ Failed ❌ Log
smoke (app) 11 11 0 0 ✅ 131347065903
smoke (fastcgi) 5 5 0 0 ✅ 131347065829
smoke (kubernetes) 8 8 0 0 ✅ 131347066010
smoke (lambda) 2 2 0 0 ✅ 131347065743
smoke (lambda-image) 5 5 0 0 ✅ 131347065883
smoke (lambda-stream) 2 2 0 0 ✅ 131347065660
smoke (lambda-zip) 9 9 0 0 ✅ 131347066141
smoke (lite) 4 4 0 0 ✅ 131347065920
smoke (lite-pep723) 4 4 0 0 ✅ 131347065206
All 50 50 0 0 ✅

The run of the workflow

@github-actions

Copy link
Copy Markdown
Contributor

Tests

Job Tests Passed ✅ Skipped ⚠️ Failed ❌ Log
prove (python 3.12, Asyncio) 7469 7440 29 0 ✅ 131347065892
prove (python 3.12, Poll) 7441 7410 31 0 ✅ 131347065939
prove (python 3.13, Asyncio) 7469 7440 29 0 ✅ 131347066041
prove (python 3.13, Poll) 7441 7410 31 0 ✅ 131347066099
prove (python 3.14, Asyncio) 7500 7476 24 0 ✅ 131347065911
prove (python 3.14, Poll) 7472 7446 26 0 ✅ 131347066194
prove (python 3.15, Asyncio) 7500 7476 24 0 ✅ 131347065711
prove (python 3.15, Poll) 7472 7446 26 0 ✅ 131347066328
prove (python 3.15t, Asyncio) 7500 7476 24 0 ✅ 131347066140
prove (python 3.15t, Poll) 7472 7446 26 0 ✅ 131347065462
prove (python mise, Asyncio) 7579 7544 35 0 ✅ 131347065747
prove (python mise, Asyncio, Windows) 7300 7234 66 0 ✅ 131347065319
prove (python mise, Poll) 7551 7514 37 0 ✅ 131347065709
prove (python mise, Poll, Windows) 7272 7204 68 0 ✅ 131347065812
prove (python pypy3.12, Asyncio) 7469 7440 29 0 ✅ 131347065699
prove (python pypy3.12, Poll) 7441 7410 31 0 ✅ 131347065914
pytest (python 3.12, ubuntu-26.04-arm) 442 416 26 0 ✅ 131347066038
pytest (python 3.15, ubuntu-26.04-arm) 442 421 21 0 ✅ 131347065729
pytest (python 3.15, windows-2025) 442 393 49 0 ✅ 131347066316
servers (python 3.12) 54 54 0 0 ✅ 131347065624
servers (python 3.15) 53 53 0 0 ✅ 131347065637
All 120781 120149 632 0 ✅

The run of the workflow

@dex4er
dex4er merged commit 2ef9633 into main Nov 12, 2026
36 checks passed
@dex4er
dex4er deleted the mojolicious-9.54 branch November 12, 2026 17:13
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.

Upstream: synchronization with Mojolicious 9.54

1 participant