WebThingsIO/webthing-node

Unhandled promise in start() of WebThingServer

Closed this issue · 0 comments

The error case of every promise needs to be handled, otherwise Node 10 might kill the process.

Code location of an unhandled promise:
https://github.com/mozilla-iot/webthing-node/blob/aed7d52ba8f80d7acf14216e1edd4484cefef265/lib/server.js#L754-L766

Add .catch(console.error); to the last line of the code location above to make it debuggable.

Steps to reproduce

const {SingleThing, Thing, WebThingServer} = require('webthing');

class TestThing extends Thing {}

const thing = new TestThing();
const server = new WebThingServer(new SingleThing(thing), 100000);
server.start();

Expected

The server fails to start. In this case it’s because the port is outside the valid TCP range. It could also fail because of the port being taken or other network configuration issues.

Actual

With Node 10.9.0 no error is shown and the application quits.