Skip to content

Commit 7b223fa

Browse files
committed
Fix connectionless inside connectionful. Closes #3414
1 parent b0e37ab commit 7b223fa

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

lib/plugin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ internals.Plugin.prototype.register = function (plugins /*, [options], callback
310310
}
311311

312312
if (connectionless) {
313-
selection.connection = this.connection;
313+
selection.connection = this.root.connection;
314314
}
315315

316316
// Register

npm-shrinkwrap.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "hapi",
33
"description": "HTTP Server framework",
44
"homepage": "http://hapijs.com",
5-
"version": "16.0.2",
5+
"version": "16.0.3",
66
"repository": {
77
"type": "git",
88
"url": "git://github.com/hapijs/hapi"

test/plugin.js

+38
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,44 @@ describe('Plugin', () => {
13421342
});
13431343
});
13441344

1345+
it('register nested connectionless plugin inside non-connectionless', (done) => {
1346+
1347+
const b = function (srv, options, next) {
1348+
1349+
if (!srv.connection) {
1350+
return next(new Error('Missing connection()'));
1351+
}
1352+
1353+
return next();
1354+
};
1355+
1356+
b.attributes = {
1357+
name: 'b',
1358+
connections: false
1359+
};
1360+
1361+
const a = function (srv, options, next) {
1362+
1363+
srv.register(b, (err) => {
1364+
1365+
expect(err).to.not.exist();
1366+
return next();
1367+
});
1368+
};
1369+
1370+
a.attributes = {
1371+
name: 'a'
1372+
};
1373+
1374+
const server = new Hapi.Server();
1375+
server.connection();
1376+
server.register(a, (err) => {
1377+
1378+
expect(err).to.not.exist();
1379+
done();
1380+
});
1381+
});
1382+
13451383
it('throws when nested connectionless plugins select', (done) => {
13461384

13471385
const b = function (srv, options, next) {

0 commit comments

Comments
 (0)