New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: update module version mismatch error message #8391

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
7 participants
@jasnell
Member

jasnell commented Sep 2, 2016

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

src

Description of change

Fixes: #8379

@addaleax

This comment has been minimized.

Member

addaleax commented Sep 2, 2016

It might be kind of cool to have the file name in there, too.

LGTM with or without that

@jasnell

This comment has been minimized.

Member

jasnell commented Sep 2, 2016

I don't believe there's currently a way of testing this in our CI but... just to make sure I didn't break anything: https://ci.nodejs.org/job/node-test-pull-request/3929/

@targos

View changes

src/node.cc Outdated
"This module was compiled against a different Node.js version "
"using NODE_MODULE_VERSION %d. This version of Node.js requires "
"NODE_MODULE_VERSION %d. Please try re-compiling or re-installing "
"the module (for instance, using `npm install` or `npm rebuild`).",

This comment has been minimized.

@targos

targos Sep 2, 2016

Member

I would use the same order than the line before: npm rebuild corresponds to re-compiling and npm install to re-installing.

This comment has been minimized.

@jasnell

jasnell Sep 2, 2016

Member

Good catch :-)

@targos

This comment has been minimized.

Member

targos commented Sep 2, 2016

Did you try locally with a manual bump of NODE_MODULE_VERSION ?

@jasnell

This comment has been minimized.

Member

jasnell commented Sep 2, 2016

before adding the *filename in the latest bump, yes. Will need to try it again in just a bit.

@addaleax

This comment has been minimized.

Member

addaleax commented Sep 2, 2016

If you want CI testing for this, an addon like this should always fail when require()ing it:

#include <node_version.h>
#undef NODE_MODULE_VERSION
#define NODE_MODULE_VERSION 42
#include <node.h>

namespace {

inline void Initialize(v8::Local<v8::Object> exports,
                       v8::Local<v8::Value> module,
                       v8::Local<v8::Context> context) {
}

}

NODE_MODULE_CONTEXT_AWARE(binding, Initialize)
@jasnell

This comment has been minimized.

Member

jasnell commented Sep 2, 2016

Added a quick test case! Thanks @addaleax :-)

@addaleax

This comment has been minimized.

Member

addaleax commented Sep 2, 2016

@Fishrock123

View changes

src/node.cc Outdated
"The module '%s' was compiled against a different Node.js version "
"using NODE_MODULE_VERSION %d. This version of Node.js requires "
"NODE_MODULE_VERSION %d. Please try re-compiling or re-installing "
"the module (for instance, using `npm rebuild` or `npm install`).",

This comment has been minimized.

@Fishrock123

Fishrock123 Sep 2, 2016

Member

Some line breaks would be nice.

This comment has been minimized.

@jasnell

jasnell Sep 2, 2016

Member

Line breaks added

@jasnell jasnell force-pushed the jasnell:module_version_mismatch branch Sep 2, 2016

@jasnell

This comment has been minimized.

Member

jasnell commented Sep 4, 2016

CI green except for known flaky

@benjamingr

This comment has been minimized.

Member

benjamingr commented Sep 4, 2016

LGTM

@Fishrock123

View changes

src/node.cc Outdated
@@ -2402,8 +2402,11 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
char errmsg[1024];
snprintf(errmsg,
sizeof(errmsg),
"Module version mismatch. Expected %d, got %d.",
NODE_MODULE_VERSION, mp->nm_version);
"The module '%s' was compiled against a different Node.js version"

This comment has been minimized.

@Fishrock123

Fishrock123 Sep 6, 2016

Member

I think it may be useful to split after the module name, e.g. output can currently become:

Error: The module '/Users/Jeremiah/Documents/node/test/addons/node-module-version/build/Release/binding.node' was compiled against a different Node.js version
using NODE_MODULE_VERSION 42. This version of Node.js requires
NODE_MODULE_VERSION 48. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).

which renders as

Error: The module '/Users/Jeremiah/Documents/node/test/addons/node-module-
version/build/Release/binding.node' was compiled against a different Node.js version
using NODE_MODULE_VERSION 42. This version of Node.js requires
NODE_MODULE_VERSION 48. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).

@Trott Trott force-pushed the nodejs:master branch to c5ce7f4 Sep 21, 2016

@addaleax

This comment has been minimized.

Member

addaleax commented Sep 24, 2016

hm, ping @jasnell? Jeremiah’s suggestion sounds good to me.

@jasnell

This comment has been minimized.

Member

jasnell commented Sep 26, 2016

Yep, agreed. Just haven't been able to get back to it yet. Will try to update this later today.

@jasnell jasnell force-pushed the jasnell:module_version_mismatch branch Sep 27, 2016

@jasnell

This comment has been minimized.

Member

jasnell commented Sep 27, 2016

Updated, PTAL

test/addons/node-module-version/test.js Outdated
const assert = require('assert');
assert.throws(() => require('./build/Release/binding'),
/was compiled against a different Node.js version/);

This comment has been minimized.

@cjihrig

cjihrig Sep 27, 2016

Contributor

Could you add the module versions to the error message check?

This comment has been minimized.

@jasnell

@jasnell jasnell force-pushed the jasnell:module_version_mismatch branch to a1abcd4 Oct 8, 2016

@jasnell

This comment has been minimized.

Member

jasnell commented Oct 8, 2016

@cjihrig ... PTAL

@cjihrig

cjihrig approved these changes Oct 8, 2016

@jasnell

This comment has been minimized.

Member

jasnell commented Oct 8, 2016

jasnell added a commit that referenced this pull request Oct 10, 2016

src: update module version mismatch error message
Fixes: #8379
PR-URL: #8391
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@jasnell

This comment has been minimized.

Member

jasnell commented Oct 10, 2016

Landed in a6e1be4.
@nodejs/ctc ... any objections to this landing in v7.x?

@jasnell jasnell closed this Oct 10, 2016

jasnell added a commit that referenced this pull request Oct 10, 2016

src: update module version mismatch error message
Fixes: #8379
PR-URL: #8391
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>

@gibfahn gibfahn referenced this pull request Jun 15, 2017

Closed

Auditing for 6.11.1 #230

2 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment