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

Process hangs after logging #41

Closed
betweenbrain opened this issue Apr 8, 2016 · 1 comment
Closed

Process hangs after logging #41

betweenbrain opened this issue Apr 8, 2016 · 1 comment

Comments

@betweenbrain
Copy link

Hello,

I am testing your transport for Winston and for some reason it seems to be logging, but also causes my script to hang. My complete script is as follows:

var mysql   = require('mysql');
var winston = require('winston');

winston.add(require('winston-graylog2'),
    {
        name: "Graylog",
        level: "info",
        silent: false,
        handleExceptions: false,
        graylog: {
            servers: [
                {
                    host: "localhost",
                    port: 12201
                }
            ],
            hostname: "test server",
            bufferSize: 1400
        },
        staticMeta: {
            application: "Test Job",
            job: "test log job"
        }
    }
);

var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '',
    database: 'test'
});

connection.connect(function (err) {

    if (err) {
        winston.log('info', 'error connecting: ' + err.stack);
    }

    winston.log('info', 'connected as id ' + connection.threadId);
});

connection.query("SELECT COUNT(*) AS count FROM consumers", function (error, results, fields) {
    winston.log('info', 'Querying clients table');

    if (!error) {
        winston.log('info', 'Count: ' + results[0].count)
    }
    if (error) {
        winston.log('info', 'Query error ' + error);
    }
});

connection.end(function (error) {
    if (!error) {
        winston.log('info', 'Closing ' + connection.threadId);
    }
    if (error) {
        winston.log('info', 'Error closing connection: ' + error);
    }
});

If I omit the winston-graylog2 require, it works fine, and completes immediately.

Any ideas? Thanks in advance for any help that you can provide.

@odino
Copy link
Contributor

odino commented Apr 9, 2016

hey @betweenbrain thanks for reporting this :)

Unfortunately, it's a known issue (see #24), meaning that the problem is that unless the connection to graylog is closed, the script wont terminate. Im closing this for now since we already have #24 but we'd be happy to review PRs as this is something we banged our head against as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants