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

Decorators fail with nested require calls #2760

Closed
kpdecker opened this issue Sep 7, 2015 · 2 comments
Closed

Decorators fail with nested require calls #2760

kpdecker opened this issue Sep 7, 2015 · 2 comments
Assignees
Labels
Milestone

Comments

@kpdecker
Copy link
Contributor

@kpdecker kpdecker commented Sep 7, 2015

When register is called within another register call, the nested dependency does not seem to decorate the server:

        it('exposes server decorations to next register when nested', function (done) {

            var server = new Hapi.Server();
            server.connection();

            var a = function (srv, options, next) {

                srv.decorate('server', 'a', function () {

                    return 'a';
                });

                return next();
            };

            a.attributes = {
                name: 'a'
            };

            var b = function (srv, options, next) {

                srv.register([a], function(err) {

                    expect(err).to.not.exist();
                    return next(typeof srv.a === 'function' ? null : new Error('Missing decoration'));
                });
            };

            b.attributes = {
                name: 'b'
            };

            server.register([b], function (err) {

                expect(err).to.not.exist();
                server.initialize(function (err) {

                    expect(err).to.not.exist();
                    done();
                });
            });
        });

Fails with:

  271) Plugin register() exposes server decorations to next register when nested:

      Missing decoration

      at ./test/plugin.js:1019:36

Related to #2727

@devinivy
Copy link
Member

@devinivy devinivy commented Sep 8, 2015

Also related to #2759, an issue with decorators in after callbacks. Just to totally clarify– this is >=9.0.4, yes?

@kpdecker
Copy link
Contributor Author

@kpdecker kpdecker commented Sep 8, 2015

Latest master

@hueniverse hueniverse added the bug label Sep 8, 2015
@hueniverse hueniverse self-assigned this Sep 8, 2015
@hueniverse hueniverse added this to the 9.3.1 milestone Sep 8, 2015
@hueniverse hueniverse closed this in a424739 Sep 8, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants