Faulty hostname check promise handling in greenlock/worker.js #71

Open
opened 2021-03-12 15:27:37 +00:00 by Ghost · 1 comment

Having recenly deployed a site using grenlock-express with cluster: true, we're seeing the following error, logged consistantly:

debug: ignoring servername "invalid.hostnameHere.com"
(it's probably either missing from your config, or a bot)
undefined (more info available: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17)
Unexpected and uncaught greenlock.notify error:
TypeError: Cannot read property 'then' of undefined
at rpc (/app/node_modules/greenlock-express/master.js:137:17)
at Worker.handleMessage (/app/node_modules/greenlock-express/master.js:156:13)
at Worker.emit (events.js:327:22)
at ChildProcess. (internal/cluster/worker.js:33:12)
at ChildProcess.emit (events.js:315:20)
at emit (internal/child_process.js:903:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)

where in these cases, obviously there's valid DNS pointing the IP on which greenlock-express is listening, but (intentionally) there is no certificate for that name. My reasding of the greenlock-express docs suggest this should be handled clanly, with a complete promise-based workflow.

I took note of the vhosts example. Do we need to write our own hostname handlers, to more cleanly deal with this issue, as in that example? Please advise.

Having recenly deployed a site using grenlock-express with cluster: true, we're seeing the following error, logged consistantly: debug: ignoring servername "invalid.hostnameHere.com" (it's probably either missing from your config, or a bot) undefined (more info available: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17) Unexpected and uncaught greenlock.notify error: TypeError: Cannot read property 'then' of undefined at rpc (/app/node_modules/greenlock-express/master.js:137:17) at Worker.handleMessage (/app/node_modules/greenlock-express/master.js:156:13) at Worker.emit (events.js:327:22) at ChildProcess.<anonymous> (internal/cluster/worker.js:33:12) at ChildProcess.emit (events.js:315:20) at emit (internal/child_process.js:903:12) at processTicksAndRejections (internal/process/task_queues.js:81:21) where in these cases, obviously there's valid DNS pointing the IP on which greenlock-express is listening, but (intentionally) there is no certificate for that name. My reasding of the greenlock-express docs suggest this should be handled clanly, with a complete promise-based workflow. I took note of the vhosts example. Do we need to write our own hostname handlers, to more cleanly deal with this issue, as in that example? Please advise.
Author

Took me an age to find out where to do this, but it's pretty easy. Just add this to the object passed to the init function in your server.js

 notify: function(ev, args) {
            
            if(ev === 'error' && (args.code === 'INVALID_HOSTNAME' || args.code === 'servername_unknown') || args.code === 'servername_invalid') {
                return;
            }

            if ('error' === ev || 'warning' === ev) {
                console.error(ev, args);
                return;
            }
            console.info(ev, args);
}
Took me an age to find out where to do this, but it's pretty easy. Just add this to the object passed to the init function in your server.js ``` notify: function(ev, args) { if(ev === 'error' && (args.code === 'INVALID_HOSTNAME' || args.code === 'servername_unknown') || args.code === 'servername_invalid') { return; } if ('error' === ev || 'warning' === ev) { console.error(ev, args); return; } console.info(ev, args); } ```
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: root/greenlock-express.js#71
No description provided.