boyney123 / garie-lighthouse

Lighthouse Garie plugin. Polls websites to checkout performance metrics also supports webhooks.
MIT License
50 stars 24 forks source link

Upgrade to Latest Lighthouse 5.2 #24

Open nateclarks opened 4 years ago

nateclarks commented 4 years ago

Hi the lighthouse npm package is out of date. I tried to update the package.json to lighthouse 5.2 and the dockerfile to the node 10 base layer ( as lighthouse 5.2 depends on node 10) but when I do so it fails to work with influx?

garie-lighthouse_1 | Application listening on port 3000 garie-lighthouse_1 | (node:19) UnhandledPromiseRejectionWarning: Failed to initialise influx garie-lighthouse_1 | (node:19) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

I tried removing the try catch on the influxdb initialise which allows lighthouse to then run but it then doesn't write to influx

thanks :)

MarcoFaul commented 4 years ago

Hi @nateclarks, did you find any solution to this problem?

danipolo commented 4 years ago

Same problem here :(

GerardSmit commented 4 years ago

@nateclarks @MarcoFaul the problem is the function init() in influx/index.js. The function is async but returns a Promise. Also, the try-catch isn't working because it's returning a promise instead of awaiting it.

You'll need to change the function to be fully async-await. See the example below. I won't make a pull request since there are 5 PR's where one is still open since 2018 and didn't have any response by the owner of the repository.

File: src/influx/index.js Line 4 - 20 Source: Fork (GerardSmit/garie-lighthouse)

/**
 * Bootstrap the database
 */
const init = async () => {
    try {
        const names = await influx.getDatabaseNames();
        if (names.indexOf('lighthouse') === -1) {
            logger.info('InfluxDB: lighthouse database does not exist. Creating database');
            await influx.createDatabase('lighthouse');
            logger.info('InfluxDB: lighthouse database created');
        }
        logger.info('InfluxDB', 'lighthouse database already exists. Skipping creation.');
    } catch (err) {
        throw new Error('Failed to initialise influx: ' + err)
    }
};
Kiina commented 3 years ago

Also works with lighthouse 6.4 and node 14.15-slim lts. Maybe you can update it in your fork and open a merge request? I don't have many high hopes of it getting merged when looking at it, but maybe it's easier for people to find then.