This should be fixed by
https://github.com/discourse/discourse/commit/9f558d7e74118d8dc0cb1db04f2b7200f5a3618c
This is a little bit touchy to modify this code, I tried various combinations an didn’t see any regression, please let me know if something doesn’t seem right.