I have a Middleman site which has always built successfully, but which now fails to build or serve. Whenever it tries to build or serve an HTML page, it throws errors of the form:
Content-Length header was 16615, but should be 16624
(the difference between expected and actual always seems to be 9 bytes). The source code hasn’t changed significantly, so apparently something has changed in my Gems to trigger this issue, but I’m having trouble identifying the culprit.
After Googling, my first thought was that it was a minification issue – I found some reports of bugs with earlier versions of Middleman – but removing the ‘:activate minify_html’ from my ‘configure :build do’ block didn’t make any difference. In any case, the issue also occurs when I run ‘bundle exec middleman server’, which should do no minification at all.
From the stack trace, it looks as if the problem is a failing assert in rack/lint.rb’s ‘verify_content_length’ method; the closest part of the Middleman code is in ‘middleman-core/builder.rb’.
Middleman version is 4.3.5, and Ruby is 2.6.5 (although I’ve had the issue with other versions). Another Middleman site using the same gems builds successfully on the same machine, suggesting that whatever the issue is, it’s very specific to this particular Middleman site. I also get the same errors trying to build the site on a different host and OS.
Can anyone suggest where I should even start looking to try to figure out what’s happening here? Are there known issues with recent Rubies and/or Gems that can trigger this type of error?