Sharp: Why did bumping Sharp fix this issue

Created on 10 Nov 2019  路  2Comments  路  Source: lovell/sharp

Not really an issue since I've fixed this, but wanted to know why the fix actually fixed it.
Node 12, Win7 x64, Electron 7 (ABI 75)

I'm using image-thumbnail which relies on Sharp, in a React/Electron 7/Webpack app, and on installation, it uses sharp 0.22.1 which gave this gyp error on compile:

e:\github\rootnav3\node_modules\sharp\src\stats.cc(130): error C2661: 'v8::Object::Set': no overloaded function takes 2 arguments [E:\Github\RootNav3\node_modules\sharp\build\sharp.vcxproj]

which results in:

gyp ERR! build error
    gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
    gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
    gyp ERR! System Windows_NT 6.1.7601
    gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"

I could get this to build by going into Sharp's folder and gyp configure/building which resulted in ABI mismatches. I think I could electron-rebuild this to get a "Module did not self-register" after that, but I had to be _in_ Sharp's folder when calling rebuild, else the gyp error occured.

A load of testing lead me to change the Sharp dep from 0.22.1 to 0.23.2, npm install in module folder, built fine, electron rebuilt, ta da, success. So I forked the repo and bumped version and it compiles fine now on its own.

So, why did bumping from 0.22.1 to 0.23.2 fix this gyp error? I read 0.22.1 was where Node 12 support was added, and I feel like it's too early in the installation to run into Electron ABI errors. Curiousity needs satisfying here (also so I can PR this into the real module with a good reason). I don't know a whole lot about how native modules _actually work_ in regards to gyp etc.

question

Most helpful comment

The ABI versions refer to the Node ABI and not the V8 API or ABI. The version of V8 in Electron does not quite line up with the version of V8 in Node.

This means you might sometimes see compiler deprecation warnings from V8 in a given Node ABI that become compiler errors from an "Node ABI compatible" Electron.

This affects all native Node.js modules and is not unique to sharp.

All 2 comments

The ABI versions refer to the Node ABI and not the V8 API or ABI. The version of V8 in Electron does not quite line up with the version of V8 in Node.

This means you might sometimes see compiler deprecation warnings from V8 in a given Node ABI that become compiler errors from an "Node ABI compatible" Electron.

This affects all native Node.js modules and is not unique to sharp.

I hope this information helped. Please feel free to re-open with more details if further help is required.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AVVS picture AVVS  路  3Comments

Andresmag picture Andresmag  路  3Comments

emmtte picture emmtte  路  3Comments

jaekunchoi picture jaekunchoi  路  3Comments

tomercagan picture tomercagan  路  3Comments