Skip to content
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 from

Conversation

jasnell
Copy link
Member

@jasnell 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

@jasnell jasnell added module Issues and PRs related to the module subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. lib / src Issues and PRs related to general changes in the lib or src directory. error-handling labels Sep 2, 2016
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Sep 2, 2016
@addaleax
Copy link
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
Copy link
Member Author

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/

"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`).",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch :-)

@targos
Copy link
Member

targos commented Sep 2, 2016

Did you try locally with a manual bump of NODE_MODULE_VERSION ?

@jasnell
Copy link
Member Author

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
Copy link
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
Copy link
Member Author

jasnell commented Sep 2, 2016

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

@addaleax
Copy link
Member

addaleax commented Sep 2, 2016

"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`).",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some line breaks would be nice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line breaks added

@jasnell
Copy link
Member Author

jasnell commented Sep 4, 2016

CI green except for known flaky

@benjamingr
Copy link
Member

LGTM

@@ -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"
Copy link
Contributor

@Fishrock123 Fishrock123 Sep 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`).

@addaleax
Copy link
Member

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

@jasnell
Copy link
Member Author

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
Copy link
Member Author

jasnell commented Sep 27, 2016

Updated, PTAL

const assert = require('assert');

assert.throws(() => require('./build/Release/binding'),
/was compiled against a different Node.js version/);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jasnell
Copy link
Member Author

jasnell commented Oct 8, 2016

@cjihrig ... PTAL

@jasnell
Copy link
Member Author

jasnell commented Oct 8, 2016

jasnell added a commit that referenced this pull request Oct 10, 2016
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
Copy link
Member Author

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
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 mentioned this pull request Jun 15, 2017
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. module Issues and PRs related to the module subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants