When editing and saving extremely long posts (around 100,000 characters), we encountered a backend timeout issue. The server becomes unresponsive during the save operation, resulting in 502/504 errors. The frontend console shows the following error stack:
ajax-error.js:36:15
l ajax-error.js:36
u ajax-error.js:75
d ajax-error.js:84
Ember 41
update rest.js:72
update rest.js:72
save rest.js:115
editPost composer.js:1147
Ember 6
I performed some comparative tests which suggest the bottleneck is in the diff calculation between old and new versions:
- Directly editing a long post A into long post B and saving consistently triggers a 502/504 timeout.
- Clearing the long post first, saving a short placeholder (e.g. 5 characters), then pasting the full new content B and saving completes quickly.
It seems the current Diff engine struggles with extreme cases involving very long text combined with a high percentage of changes. Would it be possible to add a performance fallback mechanism? For example, when the text is extremely long and the modification ratio is high, the system could treat it as a “Complete Rewrite” instead of performing a detailed line-by-line diff.
Does the team have any plans to optimize the Diff handling for large posts, or introduce some kind of graceful degradation / protection for such scenarios? Another idea is to allow the save to succeed first, and compute the diff asynchronously afterwards.