Chrome `pageCapture` unable to generate MHTML

I am trying to use Chrome's pageCapture API to download a whole page but before that, I need to modify the body contents. When I try to do that, i get the following error: Unchecked runtime.lastError: Failed to generate MHTML. Everything seems to work if I don't modify the inner HTML. This is the code:

// Works without this:
chrome.tabs.executeScript(, {
    code: 'document.body.innerHTML = <div>Something</div>'
// Wait a bit to update the content
setTimeout(() => {
    }, mhtmlData => {
        // Breaks here:
}, 200);

Any help on how I could work around this?