502 error on large previews when SESSION_ENGINE is set to signed_cookies
See original GitHub issueIssue Summary
We are trying to preview a page on wagtail. It seems previews are store in session unlike drafts. And we have a huge description text. So we are getting 502 error on preview.
Cookie length should be less than or equal to 4096 characters.
Drafts and live are working fine with this session engine.
Steps to Reproduce
- Set
SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'
in settings.py - login to cms
- go tp pages
- create a new child page or edit existing.
- Add big text in description i.e sample text
- click preview
cc @pdpinch
Screens:
Technical details
- Python version: 3.6
- Django version: 2.0.2
- SESSION_ENGINE = ‘django.contrib.sessions.backends.signed_cookies’
- Wagtail version: 2.0
- Browser version: chrome Version 66.0.3359.139 (Official Build) (64-bit) osx
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How To Fix a 502 Bad Gateway Error - Kinsta
The 502 Bad Gateway error specifically means that the server received an invalid response from an inbound server.
Read more >502 Bad Gateway Error - Support Center - WP Engine
Any 50x error means that some request to the server didn't return a proper result. A 502 specifically means that there was a...
Read more >What is a 502 Bad Gateway and how do you fix it? - IT PRO
A 502 Bad Gateway error rarely lasts very long and is usually in the process of being solved by the site administrator by...
Read more >502 Bad Gateway - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 502 Bad Gateway server error response code indicates that the server, while acting as a gateway or proxy, ......
Read more >502 Bad Gateway Error [Solved] - freeCodeCamp
But sometimes, the browser might show this error due to past-due updates, ad-blockers, browser extensions and plugins, or even DNS server ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@blarghmatey By definition, I think a preview has to show the outcome of a proposed change without committing that change to the database (even just as a draft revision). If an editor hits preview, and then changes their mind about their edit, and navigates away without saving, the system should behave as if the edit was never made at all (and thus revisiting the edit view should take you back to the page’s original state).
Thanks for the report @amir-qayyum-khan.
For reference, preview data is stored in the session since #3383. While #3583 reduces preview data size, the issue will essentially still exists.
The fact that it might exceed the cookies max-size was raised at the time but it was agreed to add a warning to the documentation (although it seems to have never happened) given that not using the session probably meant creating an API endpoint which would have been a lot more work. Maybe it will be time to revisit this.
In the meantime, you should be able to configure uwsgi to accept bigger cookies (IRRC, nginx has some sort of auto-scaling but uwsgi doesn’t).