Fail the build when the packaged binding does not match the package version - #69
Open
iampawan wants to merge 1 commit into
Open
Fail the build when the packaged binding does not match the package version#69iampawan wants to merge 1 commit into
iampawan wants to merge 1 commit into
Conversation
…ersion
postbuild copies nodejs/lib/binding/node_setapp_binding.node into
nodejs/dist/lib/binding/, and nodejs/dist is what `main` loads. That source
directory is gitignored, so on a machine where node-gyp has not run for the
current version it holds a binding left over from an earlier one - and the
copy succeeds silently.
The binding statically links the Swift library, so the version it was built
against is the version consumers actually run, whatever package.json says.
Nothing downstream can detect or correct it.
This adds a check to the end of postbuild comparing the copied binary's
embedded __scv__ stamp with the package version, and fails the build on a
mismatch.
scripts/ is outside the tsconfig include ("nodejs") and outside the published
files list, so it is neither compiled nor shipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #68.
The problem
postbuildcopiesnodejs/lib/binding/node_setapp_binding.nodeintonodejs/dist/lib/binding/, andnodejs/distis whatmainloads. That source directory is gitignored, so on a machine where node-gyp has not run for the current version it holds a binding left over from an earlier one — and the copy succeeds silently.Because the binding statically links the Swift library, the version it was built against is the version consumers actually run, whatever
package.jsonsays. Nothing downstream can detect or correct it.The published packages show the effect (versions and stamps taken straight from npm):
libSetapp.aThe full table in #68 goes back to 4.3.4;
5.1.0appears to be the only release where the two matched.The change
One check appended to
postbuild, comparing the copied binary's embedded__scv__stamp with the package version, failing the build on a mismatch.scripts/is outside the tsconfiginclude("nodejs") and outside the publishedfileslist, so it is neither compiled nor shipped.Verified
Run against real binaries on macOS 26.5 / Node 24:
5.3.3tagThe failure output:
Notes
node-gyp rebuildtobuildwould change how release artifacts are produced, which is your call to make; a check that refuses the wrong binary is safe either way. Happy to switch it to a warning if you would rather not fail the build.