#13417 closed defect (wontfix)
Trac 1.5.3 with uWSGI returns empty responses when error occured.
Reported by: | seino | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | web frontend | Version: | 1.5.3 |
Severity: | normal | Keywords: | uwsgi |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Trac 1.5.3 with uWSGI returns empty responses when error occured.
Reproduction steps:
- run Trac 1.5.3 with a newly created environment.
- try the
uwsgi_curl 127.0.0.1:8080 /
. This should be success. - try the
uwsgi_curl 127.0.0.1:8080 /zzz
. Trac returns an empty response.
Note that use uwsgi_curl
to avoid the causes related to Nginx.
$ trac-admin test initenv 新規 Trac Environment /home/user/test の生成 .. $ cat > trac.ini << 'EOF' [uwsgi] master = true processes = 2 plugins = python3 module = trac.web.main:dispatch_request env = TRAC_ENV=/home/user/test socket = 127.0.0.1:8080 EOF $ uwsgi --ini trac.ini [uWSGI] getting INI configuration from trac.ini *** Starting uWSGI 2.0.18 (64bit) on [Fri Aug 27 07:19:29 2021] *** compiled with version: 11.0.0 20210123 (Red Hat 11.0.0-0) on 27 January 2021 00:00:00 os: Linux-5.13.12-200.fc34.x86_64 #1 SMP Wed Aug 18 13:27:18 UTC 2021 nodename: hostname machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 2 current working directory: /home/user detected binary path: /usr/sbin/uwsgi your processes number limit is 3697 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uwsgi socket 0 bound to TCP address 127.0.0.1:8080 fd 5 Python version: 3.9.6 (default, Jul 16 2021, 00:00:00) [GCC 11.1.1 20210531 (Red Hat 11.1.1-3)] *** Python threads support is disabled. You can enable it with --enable-threads *** Python main interpreter initialized at 0x199af50 your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 218760 bytes (213 KB) for 2 cores *** Operational MODE: preforking *** WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x199af50 pid: 100426 (default app) *** uWSGI is running in multiple interpreter mode *** spawned uWSGI master process (pid: 100426) spawned uWSGI worker 1 (pid: 100427, cores: 1) spawned uWSGI worker 2 (pid: 100428, cores: 1) [pid: 100427|app: 0|req: 1/1] () {16 vars in 159 bytes} [Fri Aug 27 07:19:32 2021] GET / => generated 9147 bytes in 759 msecs (HTTP/1.1 200) 5 headers in 310 bytes (0 switches on core 0) [pid: 100428|app: 0|req: 1/2] () {16 vars in 165 bytes} [Fri Aug 27 07:19:35 2021] GET /zzz => generated 0 bytes in 689 msecs (HTTP/1.1 404) 5 headers in 317 bytes (0 switches on core 0)
Attachments (0)
Change History (4)
comment:1 by , 3 years ago
Component: | general → web frontend |
---|---|
Keywords: | uwsgi added |
comment:2 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Thank you for your response. I understood where this defect derived from.
For the time being, I use my private patch such as followings.
-
trac/web/api.py
diff --git a/trac/web/api.py b/trac/web/api.py index a855197..8e0ac6a 100644
a b class Request(object): 700 700 self.send_header('X-XSS-Protection', 0) 701 701 self._send_configurable_headers() 702 702 self._send_cookie_headers() 703 self._write = self._start_response(self._status, self._outheaders, 704 exc_info) 703 self._write = self._start_response(self._status, self._outheaders) 705 704 706 705 def check_modified(self, datetime, extra=''): 707 706 """Check the request "If-None-Match" header against an entity tag.
I hope for an early release of Trac 1.6.
comment:3 by , 12 days ago
This is still an issue with trac 1.6 , uwsgi 2.0.28 (ticket 2278 mentioned above still open), python 3.13.2
Could you merge seino's patch as a workaround? I can't see any issues from applying it.
comment:4 by , 11 days ago
Why do you think ignoring the given exc_info
is okay? I don't understand.
uWSGI should fix the issue rather than the following dirty workaround to Trac. At least, uWSGI didn't have this issue before uWSGI supporting Python 3.
-
trac/web/api.py
diff --git a/trac/web/api.py b/trac/web/api.py index 7f8b59bdc..fbf190831 100644
a b class Request(object): 657 657 evaluate attribute lookups 658 658 """ 659 659 self.environ = environ 660 self._start_response = s tart_response660 self._start_response = self._fixup_start_response(start_response) 661 661 self._write = None 662 662 self._status = '200 OK' 663 663 self._response = None … … class Request(object): 1123 1123 for cookie in cookies.splitlines(): 1124 1124 self._outheaders.append(('Set-Cookie', cookie.strip())) 1125 1125 1126 def _fixup_start_response(self, fn): 1127 if fn.__name__ == 'uwsgi_spit': 1128 def start_response(status, response_headers, exc_info=None): 1129 if exc_info and self._write: # headers have been sent 1130 raise exc_info[1].with_traceback(exc_info[2]) 1131 return fn(status, response_headers) 1132 return start_response 1133 else: 1134 return fn 1135 1126 1136 1127 1137 __no_apidoc__ = _HTTPException_subclass_names
I consider that is a uwsgi issue filed at SystemError when sys.exc_info() passed to start_response · Issue #2278 · unbit/uwsgi.
Should we add work around for that issue?
I applied temporarily the following changes.
trac/web/api.py
Then I get the following traceback.