overhangio / tutor-ecommerce

Ecommerce plugin for Tutor
GNU Affero General Public License v3.0
17 stars 50 forks source link

E-Commerce Course Admin page threw datatable/ajax errors #14

Closed agiledigits closed 3 years ago

agiledigits commented 3 years ago

After installing the latest Tutor and enabling the discovery/e-commerce plugins, I navigated to E-Commerce Course Admin page (https://ecommerce./courses/), and the "Courses" and "Coupons" tabs would randomly throw an error message about “DataTables warning: table id=courseTable - Ajax error." Inspecting the network requests in the browser’s devtools revealed that it was the API call to “/api/v2/courses?format=datatables…” that was returning 502 Bad Gateway error.

There were entries like this in the ecommerce log:

invalid request block size: 5104 (max 4096)...skip
ecommerce_1         | [uwsgi-http key: ecommerce.<lms_root> client_addr: 172.18.0.15 client_port: 21151] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]

Then nginx log reported that “upstream prematurely closed connection while reading response header from upstream”.

It seems that we need to increase the buffer size for uwsgi, according to this: https://stackoverflow.com/questions/15878176/uwsgi-invalid-request-block-size. For Tutor it would mean adding "--buff:er-size=8196" to the following command in Dockerfile:

CMD uwsgi \
    --static-map /static=/openedx/staticfiles/ \
    --static-map /media=/openedx/media/ \
    --http 0.0.0.0:8000 \
    --thunder-lock \
    --single-interpreter \
    --enable-threads \
    --processes=${UWSGI_WORKERS:-2} \
    **--buffer-size=8196 \**
    --wsgi-file ${SERVICE_VARIANT}/wsgi.py

The related discussions are captured here: https://discuss.overhang.io/t/e-commerce-course-admin-page-threw-datatable-ajax-errors/1216/4

regisb commented 3 years ago

Thanks a lot for this @agiledigits! This will be resolved in v11.0.1, which will be released in a few minutes.