Sergei-Korneev/obsidian-local-images-plus

Global Override of Buffer.isBuffer in v0.15.9 Causes Conflict with Obsidian Git and Potentially Other Plugins

Opened this issue · 3 comments

absane commented

I recently encountered an issue with Obsidian Git throwing an exception related to Buffer.isBuffer which, after extensive troubleshooting, I traced back to the update of Local Images Plus from version 0.15.8 to 0.15.9.

The override of the global Buffer.isBuffer method in v0.15.9, aimed at addressing a Jimp buffer package issue, has inadvertently created conflicts with Obsidian Git and potentially other plugins. This global override changes the behavior of a fundamental Node.js method across all plugins sharing the environment, leading to unexpected errors and malfunctions.

Here's the relevant change from commit #48 in utils.ts:

//Jimp buffer package fix

Buffer.isBuffer = (e) => {
  
  return (
    e != null && (
    Object.getPrototypeOf(e) instanceof Uint8Array &&
    typeof e.constructor.isBuffer == "function" ) ||
    (e.isBuffer  || e._isBuffer)
    
    )

}

I suggest a localized solution to the Jimp buffer issue that steer clear of global method overrides, to ensure broader compatibility.

I am inclined to believe that, but fill out the the bug report correctly. I cannot see visual proofs, console logs etc.
https://marker.io/blog/how-to-write-bug-report

@absane I have just made some temporary fix and updated latest release. Just reinstall the plugin.

This is a duplicate of #47 and I can confirm it breaks Obsidian Git and Local REST API.