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

Events not emitted when route handler throws #3330

Closed
hueniverse opened this issue Aug 31, 2016 · 0 comments
Closed

Events not emitted when route handler throws #3330

hueniverse opened this issue Aug 31, 2016 · 0 comments
Assignees
Labels
Milestone

Comments

@hueniverse
Copy link
Contributor

@hueniverse hueniverse commented Aug 31, 2016

            const server = new Hapi.Server({ debug: false });
            server.connection();

            const updates = [];
            const test = function (srv, options, next) {

                srv.on('log', (event, tags) => updates.push(event.tags));
                srv.on('response', (request) => updates.push('response'));
                srv.on('request-error', (request, err) => updates.push('request-error'));

                return next();
            };

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

            server.route({
                method: 'GET',
                path: '/',
                handler: function (request, reply) {

                    request.server.log('1');
                    throw new Error('2');
                }
            });

            server.register(test, (err) => {

                expect(err).to.not.exist();
                server.start((err) => {

                    expect(err).to.not.exist();
                    server.inject('/', (res) => {

                        expect(res.statusCode).to.equal(500);
                        expect(updates).to.equal([['1'], 'request-error', 'response']);
                        server.stop(done);
                    });
                });
            });
        });
@hueniverse hueniverse added the bug label Aug 31, 2016
@hueniverse hueniverse self-assigned this Sep 1, 2016
@hueniverse hueniverse added this to the 15.0.3 milestone Sep 1, 2016
@hueniverse hueniverse closed this in 63f7d89 Sep 1, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 10, 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
1 participant