Skip to content

Commit

Permalink
fix: TypeError: "listener" argument must be a function
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Sep 27, 2019
1 parent c3db37d commit 5cfc61e
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/cubejs-server/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable global-require */
require('dotenv').config();
const CubejsServerCore = require('@cubejs-backend/server-core');

Expand Down Expand Up @@ -38,7 +39,7 @@ class CubejsServer {
res.end();
});
this.redirector.listen(PORT);
this.server = https.createServer(options, app);
this.server = Object.keys(options).length ? https.createServer(options, app) : https.createServer(app);
this.server.listen(TLS_PORT, err => {
if (err) {
this.server = null;
Expand All @@ -48,10 +49,12 @@ class CubejsServer {
}
this.redirector.close = util.promisify(this.redirector.close);
this.server.close = util.promisify(this.server.close);
resolve({ app, port: PORT, tlsPort: TLS_PORT, server: this.server });
resolve({
app, port: PORT, tlsPort: TLS_PORT, server: this.server
});
});
} else {
this.server = http.createServer(options, app);
this.server = Object.keys(options).length ? http.createServer(options, app) : http.createServer(app);
this.server.listen(PORT, err => {
if (err) {
this.server = null;
Expand All @@ -64,10 +67,11 @@ class CubejsServer {
}
});
} catch (e) {
this.core.event &&
(await this.core.event("Dev Server Fatal Error", {
if (this.core.event) {
await this.core.event("Dev Server Fatal Error", {
error: (e.stack || e.message || e).toString()
}));
});
}
throw e;
}
}
Expand All @@ -84,10 +88,11 @@ class CubejsServer {
this.redirector = null;
}
} catch (e) {
this.core.event &&
(await this.core.event("Dev Server Fatal Error", {
if (this.core.event) {
await this.core.event("Dev Server Fatal Error", {
error: (e.stack || e.message || e).toString()
}));
});
}
throw e;
}
}
Expand Down

0 comments on commit 5cfc61e

Please sign in to comment.