zotero-connectors
zotero-connectors copied to clipboard
SingleFile: "Message length exceeded maximum allowed length" save failure in Chrome
https://forums.zotero.org/discussion/85726/error-report-zetero-connector-failed-to-upload-webpage-snapshot
Doesn't happen if I remove the two large animations before saving.
Doesn't happen in Firefox, though deferred images — including those animations — also don't save.
The same problem happens on https://franknielsen.github.io/IG/ on Chrome 99.0.4844.82 (when right clicking on the Zotero connector and selecting "Save to Zotero > Web Page with Snapshot". The connector version is 5.0.93. I get the following error in the connector log:
[JavaScript Error: "TypeError: Error in invocation of runtime.sendMessage(optional string extensionId, any message, optional object options, optional function callback): Message length exceeded maximum allowed length.
at chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/browser-polyfill.js:669:25
at new Promise (<anonymous>)
at Proxy.asyncFunctionWrapper (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/browser-polyfill.js:668:18)
at Object.apply (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/browser-polyfill.js:696:28)
at Object.callMethodWithCookies (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/messaging_inject.js:76:30)
at Object._saveAsWebpage (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/inject/inject.js:555:43)
at async Object.saveAsWebpage (chrome-extension://ekhagklcjbdpajgpjgmbionohlpdbjgc/inject/inject.js:476:12)" {file: "[object Object]"}]
It works fine in Firefox.
In SingleFile, large messages are truncated in order to circumvent this issue. Here is below the code that achieve this:
in the content script:
https://github.com/gildas-lormeau/SingleFile/blob/16c06098e0b43097223793e0efa477549a4f4a39/src/extension/core/common/download.js#L40-L76
in the background script:
https://github.com/gildas-lormeau/SingleFile/blob/16c06098e0b43097223793e0efa477549a4f4a39/src/extension/core/bg/downloads.js#L96-L124