Browse Source

Fixed more than a hundred unhandled promise rejection issues

Kristian Vos 4 years ago
parent
commit
4169537b89

+ 3 - 1
backend/logic/actions/apis.js

@@ -77,7 +77,9 @@ module.exports = {
                 (next) => {
                     utils
                         .runJob("GET_SONGS_FROM_SPOTIFY", { title, artist })
-                        .then((songs) => next(null, songs))
+                        .then((songs) => {
+                            next(null, songs);
+                        })
                         .catch(next);
                 },
             ],

+ 3 - 1
backend/logic/actions/hooks/adminRequired.js

@@ -18,7 +18,9 @@ module.exports = function(next) {
                             table: "sessions",
                             key: session.sessionId,
                         })
-                        .then((session) => next(null, session))
+                        .then((session) => {
+                            next(null, session);
+                        })
                         .catch(next);
                 },
                 (session, next) => {

+ 3 - 1
backend/logic/actions/hooks/loginRequired.js

@@ -17,7 +17,9 @@ module.exports = function(next) {
                             table: "sessions",
                             key: session.sessionId,
                         })
-                        .then((session) => next(null, session))
+                        .then((session) => {
+                            next(null, session);
+                        })
                         .catch(next);
                 },
                 (session, next) => {

+ 6 - 2
backend/logic/actions/hooks/ownerRequired.js

@@ -21,7 +21,9 @@ module.exports = function(next) {
                             table: "sessions",
                             key: session.sessionId,
                         })
-                        .then((session) => next(null, session))
+                        .then((session) => {
+                            next(null, session)
+                        })
                         .catch(next);
                 },
                 (session, next) => {
@@ -35,7 +37,9 @@ module.exports = function(next) {
                     if (user.role === "admin") return next(true);
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
                 (station, next) => {

+ 42 - 14
backend/logic/actions/playlists.js

@@ -134,7 +134,9 @@ let lib = {
                 (next) => {
                     playlists
                         .runJob("GET_PLAYLIST", { playlistId })
-                        .then((playlist) => next(null, playlist))
+                        .then((playlist) => {
+                            next(null, playlist);
+                        })
                         .catch(next);
                 },
 
@@ -286,7 +288,9 @@ let lib = {
                 (next) => {
                     playlists
                         .runJob("GET_PLAYLIST", { playlistId })
-                        .then((playlist) => next(null, playlist))
+                        .then((playlist) => {
+                            next(null, playlist);
+                        })
                         .catch(next);
                 },
 
@@ -332,7 +336,9 @@ let lib = {
                 (next) => {
                     playlists
                         .runJob("GET_PLAYLIST", { playlistId })
-                        .then((playlist) => next(null, playlist))
+                        .then((playlist) => {
+                            next(null, playlist);
+                        })
                         .catch(next);
                 },
             ],
@@ -389,7 +395,9 @@ let lib = {
                 (res, next) => {
                     playlists
                         .runJob("UPDATE_PLAYLIST", { playlistId })
-                        .then((playlist) => next(null, playlist))
+                        .then((playlist) => {
+                            next(null, playlist);
+                        })
                         .catch(next);
                 },
             ],
@@ -437,7 +445,9 @@ let lib = {
                 (playlist, next) => {
                     utils
                         .runJob("SHUFFLE", { array: playlist.songs })
-                        .then((result) => next(null, result.array))
+                        .then((result) => {
+                            next(null, result.array);
+                        })
                         .catch(next);
                 },
 
@@ -453,7 +463,9 @@ let lib = {
                 (res, next) => {
                     playlists
                         .runJob("UPDATE_PLAYLIST", { playlistId })
-                        .then((playlist) => next(null, playlist))
+                        .then((playlist) => {
+                            next(null, playlist);
+                        })
                         .catch(next);
                 },
             ],
@@ -669,7 +681,9 @@ let lib = {
                     (next) => {
                         playlists
                             .runJob("GET_PLAYLIST", { playlistId })
-                            .then((playlist) => next(null, playlist))
+                            .then((playlist) => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
 
@@ -742,7 +756,9 @@ let lib = {
                     (next) => {
                         playlists
                             .runJob("GET_PLAYLIST", { playlistId })
-                            .then((playlist) => next(null, playlist))
+                            .then((playlist) => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
 
@@ -759,7 +775,9 @@ let lib = {
                     (res, next) => {
                         playlists
                             .runJob("UPDATE_PLAYLIST", { playlistId })
-                            .then((playlist) => next(null, playlist))
+                            .then((playlist) => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
                 ],
@@ -824,7 +842,9 @@ let lib = {
                     (res, next) => {
                         playlists
                             .runJob("UPDATE_PLAYLIST", { playlistId })
-                            .then((playlist) => next(null, playlist))
+                            .then((playlist) => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
                 ],
@@ -878,7 +898,9 @@ let lib = {
                     (next) => {
                         playlists
                             .runJob("GET_PLAYLIST", { playlistId })
-                            .then((playlist) => next(null, playlist))
+                            .then((playlist) => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
 
@@ -927,7 +949,9 @@ let lib = {
                     (res, next) => {
                         playlists
                             .runJob("UPDATE_PLAYLIST", { playlistId })
-                            .then((playlist) => next(null, playlist))
+                            .then((playlist) => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
                 ],
@@ -981,7 +1005,9 @@ let lib = {
                     (next) => {
                         playlists
                             .runJob("GET_PLAYLIST", { playlistId })
-                            .then((playlist) => next(null, playlist))
+                            .then((playlist) => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
 
@@ -1027,7 +1053,9 @@ let lib = {
                     (res, next) => {
                         playlists
                             .runJob("UPDATE_PLAYLIST", { playlistId })
-                            .then((playlist) => next(null, playlist))
+                            .then((playlist) => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
                 ],

+ 3 - 1
backend/logic/actions/punishments.js

@@ -133,7 +133,9 @@ module.exports = {
                             expiresAt,
                             punishedBy: session.userId,
                         })
-                        .then((punishment) => next(null, punishment))
+                        .then((punishment) => {
+                            next(null, punishment);
+                        })
                         .catch(next);
                 },
             ],

+ 3 - 1
backend/logic/actions/queueSongs.js

@@ -350,7 +350,9 @@ let lib = {
                             url,
                             musicOnly: false,
                         })
-                        .then((res) => next(null, res.songs))
+                        .then((res) => {
+                            next(null, res.songs);
+                        })
                         .catch(next);
                 },
                 (songIds, next) => {

+ 3 - 1
backend/logic/actions/reports.js

@@ -266,7 +266,9 @@ module.exports = {
                     if (!song) return next("Song not found.");
                     songs
                         .runJob("GET_SONG", { id: song._id })
-                        .then((response) => next(null, response.song))
+                        .then((response) => {
+                            next(null, response.song);
+                        })
                         .catch(next);
                 },
 

+ 9 - 3
backend/logic/actions/songs.js

@@ -286,7 +286,9 @@ module.exports = {
                 (next) => {
                     songs
                         .runJob("GET_SONG_FROM_ID", { songId })
-                        .then((responsesong) => next(null, response.song))
+                        .then((responsesong) => {
+                            next(null, response.song);
+                        })
                         .catch(next);
                 },
             ],
@@ -350,7 +352,9 @@ module.exports = {
                 (res, next) => {
                     songs
                         .runJob("UPDATE_SONG", { songId })
-                        .then((song) => next(null, song))
+                        .then((song) => {
+                            next(null, song);
+                        })
                         .catch(next);
                 },
             ],
@@ -401,7 +405,9 @@ module.exports = {
                     //TODO Check if res gets returned from above
                     cache
                         .runJob("HDEL", { table: "songs", key: songId })
-                        .then(() => next())
+                        .then(() => {
+                            next();
+                        })
                         .catch(next);
                 },
             ],

+ 102 - 34
backend/logic/actions/stations.js

@@ -70,7 +70,9 @@ let usersPerStationCount = {};
 //                                     table: "sessions",
 //                                     key: socket.session.sessionId,
 //                                 })
-//                                 .then((session) => next(null, session))
+//                                 .then((session) => {
+//                                      next(null, session);
+//                                  })
 //                                 .catch(next);
 //                         },
 
@@ -475,7 +477,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
             ],
@@ -521,7 +525,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION_BY_NAME", { stationName })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -532,7 +538,9 @@ module.exports = {
                             station,
                             userId: session.userId,
                         })
-                        .then((exists) => next(null, exists))
+                        .then((exists) => {
+                            next(null, exists);
+                        })
                         .catch(next);
                 },
             ],
@@ -569,7 +577,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -601,7 +611,9 @@ module.exports = {
                             table: "officialPlaylists",
                             key: stationId,
                         })
-                        .then((playlist) => next(null, playlist))
+                        .then((playlist) => {
+                            next(null, playlist);
+                        })
                         .catch(next);
                 },
 
@@ -646,7 +658,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION_BY_NAME", { stationName })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -762,7 +776,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -777,7 +793,9 @@ module.exports = {
                 (res, next) => {
                     stations
                         .runJob("UPDATE_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
             ],
@@ -829,7 +847,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -874,7 +894,9 @@ module.exports = {
                 (res, next) => {
                     stations
                         .runJob("UPDATE_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -889,7 +911,9 @@ module.exports = {
                         .runJob("GET_ROOM_SOCKETS", {
                             room: `station.${stationId}`,
                         })
-                        .then((sockets) => next(null, sockets))
+                        .then((sockets) => {
+                            next(null, sockets);
+                        })
                         .catch(next);
                 },
 
@@ -939,7 +963,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -989,7 +1015,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -1050,7 +1078,9 @@ module.exports = {
                 (res, next) => {
                     stations
                         .runJob("UPDATE_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
             ],
@@ -1104,7 +1134,9 @@ module.exports = {
                     (res, next) => {
                         stations
                             .runJob("UPDATE_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
                 ],
@@ -1159,7 +1191,9 @@ module.exports = {
                     (res, next) => {
                         stations
                             .runJob("UPDATE_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
                 ],
@@ -1214,7 +1248,9 @@ module.exports = {
                     (res, next) => {
                         stations
                             .runJob("UPDATE_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
                 ],
@@ -1269,7 +1305,9 @@ module.exports = {
                     (res, next) => {
                         stations
                             .runJob("UPDATE_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
                 ],
@@ -1328,7 +1366,9 @@ module.exports = {
                     (res, next) => {
                         stations
                             .runJob("UPDATE_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
                 ],
@@ -1374,7 +1414,9 @@ module.exports = {
                     (next) => {
                         stations
                             .runJob("GET_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
 
@@ -1396,7 +1438,9 @@ module.exports = {
                     (res, next) => {
                         stations
                             .runJob("UPDATE_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
                 ],
@@ -1448,7 +1492,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -1466,7 +1512,9 @@ module.exports = {
                 (res, next) => {
                     stations
                         .runJob("UPDATE_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
             ],
@@ -1516,7 +1564,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -1538,7 +1588,9 @@ module.exports = {
                 (res, next) => {
                     stations
                         .runJob("UPDATE_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
             ],
@@ -1813,7 +1865,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -1974,7 +2028,9 @@ module.exports = {
                 (res, next) => {
                     stations
                         .runJob("UPDATE_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
             ],
@@ -2024,7 +2080,9 @@ module.exports = {
                         if (!songId) return next("Invalid song id.");
                         stations
                             .runJob("GET_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
 
@@ -2057,7 +2115,9 @@ module.exports = {
                     (res, next) => {
                         stations
                             .runJob("UPDATE_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
                 ],
@@ -2102,7 +2162,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 
@@ -2173,7 +2235,9 @@ module.exports = {
                     (next) => {
                         stations
                             .runJob("GET_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
 
@@ -2210,7 +2274,9 @@ module.exports = {
                     (res, next) => {
                         stations
                             .runJob("UPDATE_STATION", { stationId })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
                 ],
@@ -2257,7 +2323,9 @@ module.exports = {
                 (next) => {
                     stations
                         .runJob("GET_STATION", { stationId })
-                        .then((station) => next(null, station))
+                        .then((station) => {
+                            next(null, station);
+                        })
                         .catch(next);
                 },
 

+ 21 - 7
backend/logic/actions/users.js

@@ -264,7 +264,9 @@ module.exports = {
                             key: sessionId,
                             value: sessionSchema(sessionId, user._id),
                         })
-                        .then(() => next(null, sessionId))
+                        .then(() => {
+                            next(null, sessionId);
+                        })
                         .catch(next);
                 },
             ],
@@ -496,7 +498,9 @@ module.exports = {
                             table: "sessions",
                             key: session.sessionId,
                         })
-                        .then((session) => next(null, session))
+                        .then((session) => {
+                            next(null, session);
+                        })
                         .catch(next);
                 },
 
@@ -511,7 +515,9 @@ module.exports = {
                             table: "sessions",
                             key: session.sessionId,
                         })
-                        .then(() => next())
+                        .then(() => {
+                            next();
+                        })
                         .catch(next);
                 },
             ],
@@ -560,7 +566,9 @@ module.exports = {
                 (next) => {
                     cache
                         .runJob("HGETALL", { table: "sessions" })
-                        .then((sessions) => next(null, sessions))
+                        .then((sessions) => {
+                            next(null, sessions);
+                        })
                         .catch(next);
                 },
 
@@ -744,7 +752,9 @@ module.exports = {
                             table: "sessions",
                             key: session.sessionId,
                         })
-                        .then((session) => next(null, session))
+                        .then((session) => {
+                            next(null, session);
+                        })
                         .catch(next);
                 },
 
@@ -951,7 +961,9 @@ module.exports = {
                     (next) => {
                         utils
                             .runJob("CREATE_GRAVATAR", { email: newEmail })
-                            .then((url) => next(null, url));
+                            .then((url) => {
+                                next(null, url);
+                            });
                     },
 
                     (avatar, next) => {
@@ -2026,7 +2038,9 @@ module.exports = {
                                 expiresAt,
                                 punishedBy,
                             })
-                            .then((punishment) => next(null, punishment))
+                            .then((punishment) => {
+                                next(null, punishment);
+                            })
                             .catch(next);
                     },
 

+ 3 - 1
backend/logic/api.js

@@ -52,7 +52,9 @@ class APIModule extends CoreClass {
                             next => {
                                 this.cache
                                     .runJob("HGETALL", { table: "stations" })
-                                    .then(stations => next(null, stations))
+                                    .then(stations => {
+                                        next(null, stations);
+                                    })
                                     .catch(next);
                             },
 

+ 24 - 8
backend/logic/playlists.js

@@ -31,7 +31,9 @@ class ExampleModule extends CoreClass {
                         this.setStage(3);
                         this.cache
                             .runJob("HGETALL", { table: "playlists" })
-                            .then((playlists) => next(null, playlists))
+                            .then((playlists) => {
+                                next(null, playlists);
+                            })
                             .catch(next);
                     },
 
@@ -52,7 +54,9 @@ class ExampleModule extends CoreClass {
                                                     table: "playlists",
                                                     key: playlistId,
                                                 })
-                                                .then(() => next())
+                                                .then(() => {
+                                                    next();
+                                                })
                                                 .catch(next);
                                         } else next();
                                     }
@@ -119,7 +123,9 @@ class ExampleModule extends CoreClass {
                     (next) => {
                         this.cache
                             .runJob("HGETALL", { table: "playlists" })
-                            .then((playlists) => next(null, playlists))
+                            .then((playlists) => {
+                                next(null, playlists);
+                            })
                             .catch(next);
                     },
 
@@ -139,7 +145,9 @@ class ExampleModule extends CoreClass {
                                                     table: "playlists",
                                                     key: playlistId,
                                                 })
-                                                .then(() => next())
+                                                .then(() => {
+                                                    next();
+                                                })
                                                 .catch(next);
                                         } else next();
                                     }
@@ -155,7 +163,9 @@ class ExampleModule extends CoreClass {
                                 table: "playlists",
                                 key: payload.playlistId,
                             })
-                            .then((playlist) => next(null, playlist))
+                            .then((playlist) => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
 
@@ -175,7 +185,9 @@ class ExampleModule extends CoreClass {
                                     key: payload.playlistId,
                                     value: playlist,
                                 })
-                                .then((playlist) => next(null, playlist))
+                                .then((playlist) => {
+                                    next(null, playlist);
+                                })
                                 .catch(next);
                         } else next("Playlist not found");
                     },
@@ -224,7 +236,9 @@ class ExampleModule extends CoreClass {
                                 key: payload.playlistId,
                                 value: playlist,
                             })
-                            .then((playlist) => next(null, playlist))
+                            .then((playlist) => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
                 ],
@@ -264,7 +278,9 @@ class ExampleModule extends CoreClass {
                                 table: "playlists",
                                 key: payload.playlistId,
                             })
-                            .then(() => next())
+                            .then(() => {
+                                next();
+                            })
                             .catch(next);
                     },
                 ],

+ 24 - 8
backend/logic/punishments.js

@@ -31,7 +31,9 @@ class PunishmentsModule extends CoreClass {
                         this.setStage(2);
                         this.cache
                             .runJob("HGETALL", { table: "punishments" })
-                            .then((punishments) => next(null, punishments))
+                            .then((punishments) => {
+                                next(null, punishments);
+                            })
                             .catch(next);
                     },
 
@@ -52,7 +54,9 @@ class PunishmentsModule extends CoreClass {
                                                     table: "punishments",
                                                     key: punishmentId,
                                                 })
-                                                .then(() => next())
+                                                .then(() => {
+                                                    next();
+                                                })
                                                 .catch(next);
                                         else next();
                                     }
@@ -86,7 +90,9 @@ class PunishmentsModule extends CoreClass {
                                             punishment._id
                                         ),
                                     })
-                                    .then(() => next())
+                                    .then(() => {
+                                        next();
+                                    })
                                     .catch(next);
                             },
                             next
@@ -149,7 +155,9 @@ class PunishmentsModule extends CoreClass {
                                         table: "punishments",
                                         key: punishment.punishmentId,
                                     })
-                                    .finally(() => next2());
+                                    .finally(() => {
+                                        next2()
+                                    });
                             },
                             () => {
                                 next(null, punishments);
@@ -189,7 +197,9 @@ class PunishmentsModule extends CoreClass {
                                 table: "punishments",
                                 key: payload.id,
                             })
-                            .then((punishment) => next(null, punishment))
+                            .then((punishment) => {
+                                next(null, punishment);
+                            })
                             .catch(next);
                     },
 
@@ -206,7 +216,9 @@ class PunishmentsModule extends CoreClass {
                                     key: payload.id,
                                     value: punishment,
                                 })
-                                .then((punishment) => next(null, punishment))
+                                .then((punishment) => {
+                                    next(null, punishment);
+                                })
                                 .catch(next);
                         } else next("Punishment not found.");
                     },
@@ -233,7 +245,9 @@ class PunishmentsModule extends CoreClass {
                 [
                     (next) => {
                         this.runJob("GET_PUNISHMENTS", {})
-                            .then((punishments) => next(null, punishments))
+                            .then((punishments) => {
+                                next(null, punishments);
+                            })
                             .catch(next);
                     },
                     (punishments, next) => {
@@ -294,7 +308,9 @@ class PunishmentsModule extends CoreClass {
                                     punishment._id
                                 ),
                             })
-                            .then(() => next())
+                            .then(() => {
+                                next();
+                            })
                             .catch(next);
                     },
 

+ 21 - 7
backend/logic/songs.js

@@ -31,7 +31,9 @@ class SongsModule extends CoreClass {
                         this.setStage(2);
                         this.cache
                             .runJob("HGETALL", { table: "songs" })
-                            .then((songs) => next(null, songs))
+                            .then((songs) => {
+                                next(null, songs);
+                            })
                             .catch(next);
                     },
 
@@ -50,7 +52,9 @@ class SongsModule extends CoreClass {
                                                 table: "songs",
                                                 key: songId,
                                             })
-                                            .then(() => next())
+                                            .then(() => {
+                                                next();
+                                            })
                                             .catch(next);
                                     else next();
                                 });
@@ -75,7 +79,9 @@ class SongsModule extends CoreClass {
                                         key: song.songId,
                                         value: songSchema(song),
                                     })
-                                    .then(() => next())
+                                    .then(() => {
+                                        next();
+                                    })
                                     .catch(next);
                             },
                             next
@@ -116,7 +122,9 @@ class SongsModule extends CoreClass {
                             return next("Id is not a valid ObjectId.");
                         this.cache
                             .runJob("HGET", { table: "songs", key: payload.id })
-                            .then((song) => next(null, song))
+                            .then((song) => {
+                                next(null, song);
+                            })
                             .catch(next);
                     },
 
@@ -133,7 +141,9 @@ class SongsModule extends CoreClass {
                                     key: payload.id,
                                     value: song,
                                 })
-                                .then((song) => next(null, song));
+                                .then((song) => {
+                                    next(null, song);
+                                });
                         } else next("Song not found.");
                     },
                 ],
@@ -205,7 +215,9 @@ class SongsModule extends CoreClass {
                                 key: payload.songId,
                                 value: song,
                             })
-                            .then((song) => next(null, song))
+                            .then((song) => {
+                                next(null, song);
+                            })
                             .catch(next);
                     },
                 ],
@@ -242,7 +254,9 @@ class SongsModule extends CoreClass {
                                 table: "songs",
                                 key: payload.songId,
                             })
-                            .then(() => next())
+                            .then(() => {
+                                next();
+                            })
                             .catch(next);
                     },
                 ],

+ 6 - 2
backend/logic/spotify.js

@@ -40,7 +40,9 @@ class SpotifyModule extends CoreClass {
                         this.setStage(2);
                         this.cache
                             .runJob("HGET", { table: "api", key: "spotify" })
-                            .then((data) => next(null, data))
+                            .then((data) => {
+                                next(null, data);
+                            })
                             .catch(next);
                     },
 
@@ -102,7 +104,9 @@ class SpotifyModule extends CoreClass {
                                 value: apiResults,
                                 stringifyJson: true,
                             })
-                            .finally(() => next());
+                            .finally(() => {
+                                next();
+                            });
                     },
                 ],
                 () => {

+ 33 - 11
backend/logic/stations.js

@@ -105,7 +105,9 @@ class StationsModule extends CoreClass {
                         this.setStage(2);
                         this.cache
                             .runJob("HGETALL", { table: "stations" })
-                            .then((stations) => next(null, stations))
+                            .then((stations) => {
+                                next(null, stations);
+                            })
                             .catch(next);
                     },
 
@@ -126,7 +128,9 @@ class StationsModule extends CoreClass {
                                                     table: "stations",
                                                     key: stationId,
                                                 })
-                                                .then(() => next())
+                                                .then(() => {
+                                                    next();
+                                                })
                                                 .catch(next);
                                         } else next();
                                     }
@@ -172,7 +176,9 @@ class StationsModule extends CoreClass {
                                                 },
                                                 { bypassQueue: true }
                                             )
-                                                .then(() => next())
+                                                .then(() => {
+                                                    next();
+                                                })
                                                 .catch(next); // bypassQueue is true because otherwise the module will never initialize
                                         },
                                     ],
@@ -215,7 +221,9 @@ class StationsModule extends CoreClass {
                             },
                             { bypassQueue: payload.bypassQueue }
                         )
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
                     (station, next) => {
@@ -251,7 +259,9 @@ class StationsModule extends CoreClass {
                                 },
                                 { bypassQueue: payload.bypassQueue }
                             )
-                                .then((station) => next(true, station))
+                                .then((station) => {
+                                    next(true, station);
+                                })
                                 .catch(next)
                                 .finally(() => {});
                         }
@@ -273,7 +283,9 @@ class StationsModule extends CoreClass {
                                 },
                                 { bypassQueue: payload.bypassQueue }
                             )
-                                .then((station) => next(null, station))
+                                .then((station) => {
+                                    next(null, station);
+                                })
                                 .catch(next);
                         } else {
                             //name, time, cb, station
@@ -357,7 +369,9 @@ class StationsModule extends CoreClass {
 
                         this.utils
                             .runJob("SHUFFLE", { array: playlist })
-                            .then((result) => next(null, result.array))
+                            .then((result) => {
+                                next(null, result.array);
+                            })
                             .catch(next);
                     },
 
@@ -371,7 +385,9 @@ class StationsModule extends CoreClass {
                             },
                             { bypassQueue: payload.bypassQueue }
                         )
-                            .then(() => next(null, playlist))
+                            .then(() => {
+                                next(null, playlist);
+                            })
                             .catch(next);
                     },
 
@@ -389,7 +405,9 @@ class StationsModule extends CoreClass {
                                     },
                                     { bypassQueue: payload.bypassQueue }
                                 )
-                                    .then(() => next(null, playlist))
+                                    .then(() => {
+                                        next(null, playlist);
+                                    })
                                     .catch(next);
                             }
                         );
@@ -415,7 +433,9 @@ class StationsModule extends CoreClass {
                                 table: "stations",
                                 key: payload.stationId,
                             })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
 
@@ -543,7 +563,9 @@ class StationsModule extends CoreClass {
                                 key: payload.stationId,
                                 value: station,
                             })
-                            .then((station) => next(null, station))
+                            .then((station) => {
+                                next(null, station);
+                            })
                             .catch(next);
                     },
                 ],

+ 15 - 5
backend/logic/tasks.js

@@ -112,7 +112,9 @@ class TasksModule extends CoreClass {
                             .runJob("HGETALL", {
                                 table: "stations",
                             })
-                            .then((response) => next(null, response))
+                            .then((response) => {
+                                next(null, response);
+                            })
                             .catch(next);
                     },
                     (stations, next) => {
@@ -204,7 +206,9 @@ class TasksModule extends CoreClass {
                                             table: "sessions",
                                             key: sessionId,
                                         })
-                                        .finally(() => next2());
+                                        .finally(() => {
+                                            next2();
+                                        });
                                 } else if (!session.refreshDate) {
                                     session.refreshDate = Date.now();
                                     this.cache
@@ -213,7 +217,9 @@ class TasksModule extends CoreClass {
                                             key: sessionId,
                                             value: session,
                                         })
-                                        .finally(() => next2());
+                                        .finally(() => {
+                                            next2()
+                                        });
                                 } else if (
                                     Date.now() - session.refreshDate >
                                     60 * 60 * 24 * 30 * 1000
@@ -231,7 +237,9 @@ class TasksModule extends CoreClass {
                                                         key: sessionId,
                                                         value: session,
                                                     })
-                                                    .finally(() => next2());
+                                                    .finally(() => {
+                                                        next2();
+                                                    });
                                             } else {
                                                 this.log(
                                                     "INFO",
@@ -243,7 +251,9 @@ class TasksModule extends CoreClass {
                                                         table: "sessions",
                                                         key: session.sessionId,
                                                     })
-                                                    .finally(() => next2());
+                                                    .finally(() => {
+                                                        next2();
+                                                    });
                                             }
                                         });
                                 } else {