From 573919fbfb6f0cdcfb86c19b16c58bde8525971b Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 25 Oct 2019 14:52:13 -0700 Subject: [PATCH 1/9] src: add file name to 'Module did not self-register' error --- src/node_binding.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node_binding.cc b/src/node_binding.cc index f0a148a495605c..f2479d4eaa2b20 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -484,7 +484,9 @@ void DLOpen(const FunctionCallbackInfo& args) { mp = dlib->GetSavedModuleFromGlobalHandleMap(); if (mp == nullptr || mp->nm_context_register_func == nullptr) { dlib->Close(); - env->ThrowError("Module did not self-register."); + char errmsg[1024]; + snprintf(errmsg, 1024, "Module did not self-register: '%s'.", *filename); + env->ThrowError(errmsg); return false; } } From 8b19567dbf616ac999c2f5b5700d379e1043eb85 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 25 Oct 2019 15:46:03 -0700 Subject: [PATCH 2/9] update tests --- test/addons/dlopen-ping-pong/test-worker.js | 2 +- test/addons/dlopen-ping-pong/test.js | 2 +- test/addons/not-a-binding/test.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/addons/dlopen-ping-pong/test-worker.js b/test/addons/dlopen-ping-pong/test-worker.js index feba6aa5eb0202..90a7dffa2484e6 100644 --- a/test/addons/dlopen-ping-pong/test-worker.js +++ b/test/addons/dlopen-ping-pong/test-worker.js @@ -16,5 +16,5 @@ require(bindingPath); new Worker(`require(${JSON.stringify(bindingPath)})`, { eval: true }) .on('error', common.mustCall((err) => { assert.strictEqual(err.constructor, Error); - assert.strictEqual(err.message, 'Module did not self-register.'); + assert.strictEqual(err.message, `Module did not self-register: '${bindingPath}.node'.`); })); diff --git a/test/addons/dlopen-ping-pong/test.js b/test/addons/dlopen-ping-pong/test.js index c5b8c16493f60f..dd663ed1ebfdfe 100644 --- a/test/addons/dlopen-ping-pong/test.js +++ b/test/addons/dlopen-ping-pong/test.js @@ -19,5 +19,5 @@ assert.strictEqual(module.exports.ping(), 'pong'); // Check that after the addon is loaded with // process.dlopen() a require() call fails. console.log('require:', `./build/${common.buildType}/binding`); -const re = /^Error: Module did not self-register\.$/; +const re = /^Error: Module did not self-register: '.*\/binding.node'\.$/; assert.throws(() => require(`./build/${common.buildType}/binding`), re); diff --git a/test/addons/not-a-binding/test.js b/test/addons/not-a-binding/test.js index a0ce2d0629ac1d..c67b492ad8f659 100644 --- a/test/addons/not-a-binding/test.js +++ b/test/addons/not-a-binding/test.js @@ -2,5 +2,5 @@ const common = require('../../common'); const assert = require('assert'); -const re = /^Error: Module did not self-register\.$/; +const re = /^Error: Module did not self-register: '.*\/binding.node'\.$/; assert.throws(() => require(`./build/${common.buildType}/binding`), re); From f8fff4476acf2c49ca596ca58045d1f1b3eb4e99 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Mon, 28 Oct 2019 20:55:10 -0700 Subject: [PATCH 3/9] Update node_binding.cc --- src/node_binding.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_binding.cc b/src/node_binding.cc index f2479d4eaa2b20..74ed795f75df2c 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -485,7 +485,7 @@ void DLOpen(const FunctionCallbackInfo& args) { if (mp == nullptr || mp->nm_context_register_func == nullptr) { dlib->Close(); char errmsg[1024]; - snprintf(errmsg, 1024, "Module did not self-register: '%s'.", *filename); + snprintf(errmsg, sizeof(errmsg), "Module did not self-register: '%s'.", *filename); env->ThrowError(errmsg); return false; } From 96712bff7cfd5dc2770f0034f9c7b8bf9541ce90 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Mon, 28 Oct 2019 20:55:26 -0700 Subject: [PATCH 4/9] Update test-worker.js --- test/addons/dlopen-ping-pong/test-worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/addons/dlopen-ping-pong/test-worker.js b/test/addons/dlopen-ping-pong/test-worker.js index 90a7dffa2484e6..7f0acb888e56b0 100644 --- a/test/addons/dlopen-ping-pong/test-worker.js +++ b/test/addons/dlopen-ping-pong/test-worker.js @@ -16,5 +16,5 @@ require(bindingPath); new Worker(`require(${JSON.stringify(bindingPath)})`, { eval: true }) .on('error', common.mustCall((err) => { assert.strictEqual(err.constructor, Error); - assert.strictEqual(err.message, `Module did not self-register: '${bindingPath}.node'.`); + assert.strictEqual(err.message, `Module did not self-register: '${bindingPath}'.`); })); From 6b0b6df50292508298dd95461715a7ab7fd7bb07 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Wed, 30 Oct 2019 09:53:25 -0700 Subject: [PATCH 5/9] fix lint --- test/addons/dlopen-ping-pong/test-worker.js | 3 ++- test/addons/dlopen-ping-pong/test.js | 2 +- test/addons/not-a-binding/test.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/addons/dlopen-ping-pong/test-worker.js b/test/addons/dlopen-ping-pong/test-worker.js index 7f0acb888e56b0..d24bd2df8050f2 100644 --- a/test/addons/dlopen-ping-pong/test-worker.js +++ b/test/addons/dlopen-ping-pong/test-worker.js @@ -16,5 +16,6 @@ require(bindingPath); new Worker(`require(${JSON.stringify(bindingPath)})`, { eval: true }) .on('error', common.mustCall((err) => { assert.strictEqual(err.constructor, Error); - assert.strictEqual(err.message, `Module did not self-register: '${bindingPath}'.`); + assert.strictEqual(err.message, + `Module did not self-register: '${bindingPath}'.`); })); diff --git a/test/addons/dlopen-ping-pong/test.js b/test/addons/dlopen-ping-pong/test.js index dd663ed1ebfdfe..0a8b5bbc56f0f1 100644 --- a/test/addons/dlopen-ping-pong/test.js +++ b/test/addons/dlopen-ping-pong/test.js @@ -19,5 +19,5 @@ assert.strictEqual(module.exports.ping(), 'pong'); // Check that after the addon is loaded with // process.dlopen() a require() call fails. console.log('require:', `./build/${common.buildType}/binding`); -const re = /^Error: Module did not self-register: '.*\/binding.node'\.$/; +const re = /^Error: Module did not self-register: '.*\/binding\.node'\.$/; assert.throws(() => require(`./build/${common.buildType}/binding`), re); diff --git a/test/addons/not-a-binding/test.js b/test/addons/not-a-binding/test.js index c67b492ad8f659..d3267c1a41943d 100644 --- a/test/addons/not-a-binding/test.js +++ b/test/addons/not-a-binding/test.js @@ -2,5 +2,5 @@ const common = require('../../common'); const assert = require('assert'); -const re = /^Error: Module did not self-register: '.*\/binding.node'\.$/; +const re = /^Error: Module did not self-register: '.*\/binding\.node'\.$/; assert.throws(() => require(`./build/${common.buildType}/binding`), re); From e101c46b2d93034f22aa9744d0b9b09d486c40ea Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Tue, 5 Nov 2019 15:03:32 -0800 Subject: [PATCH 6/9] lint --- src/node_binding.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node_binding.cc b/src/node_binding.cc index 74ed795f75df2c..3971e95b8332b8 100644 --- a/src/node_binding.cc +++ b/src/node_binding.cc @@ -485,7 +485,10 @@ void DLOpen(const FunctionCallbackInfo& args) { if (mp == nullptr || mp->nm_context_register_func == nullptr) { dlib->Close(); char errmsg[1024]; - snprintf(errmsg, sizeof(errmsg), "Module did not self-register: '%s'.", *filename); + snprintf(errmsg, + sizeof(errmsg), + "Module did not self-register: '%s'.", + *filename); env->ThrowError(errmsg); return false; } From 27ee4a6887d4ca40b28e9435c4e942adecc8464e Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 8 Nov 2019 13:11:31 -0800 Subject: [PATCH 7/9] Update test.js --- test/addons/dlopen-ping-pong/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/addons/dlopen-ping-pong/test.js b/test/addons/dlopen-ping-pong/test.js index 0a8b5bbc56f0f1..c8962ed2db7321 100644 --- a/test/addons/dlopen-ping-pong/test.js +++ b/test/addons/dlopen-ping-pong/test.js @@ -19,5 +19,5 @@ assert.strictEqual(module.exports.ping(), 'pong'); // Check that after the addon is loaded with // process.dlopen() a require() call fails. console.log('require:', `./build/${common.buildType}/binding`); -const re = /^Error: Module did not self-register: '.*\/binding\.node'\.$/; +const re = /^Error: Module did not self-register: '.*[\\\/]binding\.node'\.$/; assert.throws(() => require(`./build/${common.buildType}/binding`), re); From 2781529a29968b4b2b4cde86b708578df8c01bec Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 8 Nov 2019 13:11:47 -0800 Subject: [PATCH 8/9] Update test.js --- test/addons/not-a-binding/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/addons/not-a-binding/test.js b/test/addons/not-a-binding/test.js index d3267c1a41943d..f250080d42f39f 100644 --- a/test/addons/not-a-binding/test.js +++ b/test/addons/not-a-binding/test.js @@ -2,5 +2,5 @@ const common = require('../../common'); const assert = require('assert'); -const re = /^Error: Module did not self-register: '.*\/binding\.node'\.$/; +const re = /^Error: Module did not self-register: '.*[\\\/]binding\.node'\.$/; assert.throws(() => require(`./build/${common.buildType}/binding`), re); From efc6705f015bd602f665451d229d3b8d5cfd172a Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Wed, 13 Nov 2019 17:22:08 -0800 Subject: [PATCH 9/9] TIL: you don't have to escape / inside [] in a regex in JS --- test/addons/dlopen-ping-pong/test.js | 2 +- test/addons/not-a-binding/test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/addons/dlopen-ping-pong/test.js b/test/addons/dlopen-ping-pong/test.js index c8962ed2db7321..c3461d8bd269c5 100644 --- a/test/addons/dlopen-ping-pong/test.js +++ b/test/addons/dlopen-ping-pong/test.js @@ -19,5 +19,5 @@ assert.strictEqual(module.exports.ping(), 'pong'); // Check that after the addon is loaded with // process.dlopen() a require() call fails. console.log('require:', `./build/${common.buildType}/binding`); -const re = /^Error: Module did not self-register: '.*[\\\/]binding\.node'\.$/; +const re = /^Error: Module did not self-register: '.*[\\/]binding\.node'\.$/; assert.throws(() => require(`./build/${common.buildType}/binding`), re); diff --git a/test/addons/not-a-binding/test.js b/test/addons/not-a-binding/test.js index f250080d42f39f..4b4e7150ebbca2 100644 --- a/test/addons/not-a-binding/test.js +++ b/test/addons/not-a-binding/test.js @@ -2,5 +2,5 @@ const common = require('../../common'); const assert = require('assert'); -const re = /^Error: Module did not self-register: '.*[\\\/]binding\.node'\.$/; +const re = /^Error: Module did not self-register: '.*[\\/]binding\.node'\.$/; assert.throws(() => require(`./build/${common.buildType}/binding`), re);