Skip to content

Commit 5cfc61e

Browse files
committed
fix: TypeError: "listener" argument must be a function
1 parent c3db37d commit 5cfc61e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

packages/cubejs-server/index.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable global-require */
12
require('dotenv').config();
23
const CubejsServerCore = require('@cubejs-backend/server-core');
34

@@ -38,7 +39,7 @@ class CubejsServer {
3839
res.end();
3940
});
4041
this.redirector.listen(PORT);
41-
this.server = https.createServer(options, app);
42+
this.server = Object.keys(options).length ? https.createServer(options, app) : https.createServer(app);
4243
this.server.listen(TLS_PORT, err => {
4344
if (err) {
4445
this.server = null;
@@ -48,10 +49,12 @@ class CubejsServer {
4849
}
4950
this.redirector.close = util.promisify(this.redirector.close);
5051
this.server.close = util.promisify(this.server.close);
51-
resolve({ app, port: PORT, tlsPort: TLS_PORT, server: this.server });
52+
resolve({
53+
app, port: PORT, tlsPort: TLS_PORT, server: this.server
54+
});
5255
});
5356
} else {
54-
this.server = http.createServer(options, app);
57+
this.server = Object.keys(options).length ? http.createServer(options, app) : http.createServer(app);
5558
this.server.listen(PORT, err => {
5659
if (err) {
5760
this.server = null;
@@ -64,10 +67,11 @@ class CubejsServer {
6467
}
6568
});
6669
} catch (e) {
67-
this.core.event &&
68-
(await this.core.event("Dev Server Fatal Error", {
70+
if (this.core.event) {
71+
await this.core.event("Dev Server Fatal Error", {
6972
error: (e.stack || e.message || e).toString()
70-
}));
73+
});
74+
}
7175
throw e;
7276
}
7377
}
@@ -84,10 +88,11 @@ class CubejsServer {
8488
this.redirector = null;
8589
}
8690
} catch (e) {
87-
this.core.event &&
88-
(await this.core.event("Dev Server Fatal Error", {
91+
if (this.core.event) {
92+
await this.core.event("Dev Server Fatal Error", {
8993
error: (e.stack || e.message || e).toString()
90-
}));
94+
});
95+
}
9196
throw e;
9297
}
9398
}

0 commit comments

Comments
 (0)