diff --git a/nix/testVm/vm.nix b/nix/testVm/vm.nix index eccd12b..0c61aa8 100644 --- a/nix/testVm/vm.nix +++ b/nix/testVm/vm.nix @@ -6,7 +6,7 @@ }: { imports = [ - (modulesPath + "/virtualisation/qemu-vm.nix") +# (modulesPath + "/virtualisation/qemu-vm.nix") ]; virtualisation.vmVariant = { diff --git a/scripts/openapi.js b/scripts/openapi.js index 86d502e..564450e 100644 --- a/scripts/openapi.js +++ b/scripts/openapi.js @@ -256,4 +256,4 @@ ); } -main(); +main().then(() => {}); diff --git a/scripts/schema.js b/scripts/schema.js index 67c5563..6039847 100644 --- a/scripts/schema.js +++ b/scripts/schema.js @@ -380,4 +380,4 @@ return diffs; } -main(); +main().then(() => {}); diff --git a/scripts/stress/login.js b/scripts/stress/login.js index 830d6a4..9009e56 100644 --- a/scripts/stress/login.js +++ b/scripts/stress/login.js @@ -13,4 +13,4 @@ console.log((await ret.json()).token); } -main(); +main().then(() => {}); diff --git a/scripts/stress/users.js b/scripts/stress/users.js index 2fc41ea..8135368 100644 --- a/scripts/stress/users.js +++ b/scripts/stress/users.js @@ -34,9 +34,9 @@ captcha_key: null, }), headers: { "content-type": "application/json" }, - }); + }).then(() => {}); console.log(i); } } -main(); +main().then(() => {}); diff --git a/scripts/syncronise.js b/scripts/syncronise.js index 58c1802..d0fc38f 100644 --- a/scripts/syncronise.js +++ b/scripts/syncronise.js @@ -34,5 +34,5 @@ console.log("synchronising"); await db.synchronize(); console.log("done"); - db.destroy(); + await db.destroy(); })(); diff --git a/src/api/Server.ts b/src/api/Server.ts index 6a61d3c..f6c3839 100644 --- a/src/api/Server.ts +++ b/src/api/Server.ts @@ -200,7 +200,7 @@ this.app.use(ErrorHandler); - ConnectionLoader.loadConnections(); + await ConnectionLoader.loadConnections(); if (logRequests) console.log(red(`Warning: Request logging is enabled! This will spam your console!\nTo disable this, unset the 'LOG_REQUESTS' environment variable!`)); diff --git "a/src/api/routes/applications/\043application_id/bot/index.ts" "b/src/api/routes/applications/\043application_id/bot/index.ts" index 47b8a72..a5eb312 100644 --- "a/src/api/routes/applications/\043application_id/bot/index.ts" +++ "b/src/api/routes/applications/\043application_id/bot/index.ts" @@ -122,7 +122,7 @@ app.bot.assign(body); - app.bot.save(); + await app.bot.save(); await app.save(); res.json(app).status(200); diff --git "a/src/api/routes/channels/\043channel_id/messages/\043message_id/index.ts" "b/src/api/routes/channels/\043channel_id/messages/\043message_id/index.ts" index c056912..96ff98e 100644 --- "a/src/api/routes/channels/\043channel_id/messages/\043message_id/index.ts" +++ "b/src/api/routes/channels/\043channel_id/messages/\043message_id/index.ts" @@ -113,7 +113,7 @@ } as MessageUpdateEvent), ]); - postHandleMessage(new_message); + postHandleMessage(new_message).catch((e) => console.error("[Message] post-message handler failed", e)); // TODO: a DTO? return res.json({ @@ -295,7 +295,7 @@ }); if (channel.type === ChannelType.GUILD_PUBLIC_THREAD) { if (channel.message_count !== undefined) channel.message_count--; - channel.save(); //Save async, it's fine + await channel.save(); } const message = await Message.findOneOrFail({ where: { id: message_id }, diff --git "a/src/api/routes/channels/\043channel_id/messages/\043message_id/threads.ts" "b/src/api/routes/channels/\043channel_id/messages/\043message_id/threads.ts" index eb375e5..7bb119d 100644 --- "a/src/api/routes/channels/\043channel_id/messages/\043message_id/threads.ts" +++ "b/src/api/routes/channels/\043channel_id/messages/\043message_id/threads.ts" @@ -89,7 +89,7 @@ }, author_id: user.id, }); - sendMessage({ + await sendMessage({ channel_id: channel.id, type: MessageType.THREAD_CREATED, content: thread.name, diff --git "a/src/api/routes/channels/\043channel_id/threads.ts" "b/src/api/routes/channels/\043channel_id/threads.ts" index 9d10cb1..22b29e5 100644 --- "a/src/api/routes/channels/\043channel_id/threads.ts" +++ "b/src/api/routes/channels/\043channel_id/threads.ts" @@ -126,7 +126,7 @@ }), ]); if (body.type !== ChannelType.GUILD_PRIVATE_THREAD && !channel.isForum()) - sendMessage({ + await sendMessage({ channel_id: channel.id, type: MessageType.THREAD_CREATED, content: thread.name, diff --git "a/src/api/routes/connections/\043connection_name/authorize.ts" "b/src/api/routes/connections/\043connection_name/authorize.ts" index ca56bbe..b74fd86 100644 --- "a/src/api/routes/connections/\043connection_name/authorize.ts" +++ "b/src/api/routes/connections/\043connection_name/authorize.ts" @@ -43,7 +43,7 @@ }); res.json({ - url: await connection.getAuthorizationUrl(req.user_id), + url: connection.getAuthorizationUrl(req.user_id), }); }); diff --git "a/src/api/routes/connections/\043connection_name/callback.ts" "b/src/api/routes/connections/\043connection_name/callback.ts" index 2f6a25a..7fc7253 100644 --- "a/src/api/routes/connections/\043connection_name/callback.ts" +++ "b/src/api/routes/connections/\043connection_name/callback.ts" @@ -49,7 +49,7 @@ // whether we should emit a connections update event, only used when a connection doesnt already exist if (connectedAccnt) - emitEvent({ + await emitEvent({ event: "USER_CONNECTIONS_UPDATE", data: { ...connectedAccnt, token_data: undefined }, user_id: userId, diff --git "a/src/api/routes/guilds/\043guild_id/messages/search.ts" "b/src/api/routes/guilds/\043guild_id/messages/search.ts" index eb9ecd6..601d39d 100644 --- "a/src/api/routes/guilds/\043guild_id/messages/search.ts" +++ "b/src/api/routes/guilds/\043guild_id/messages/search.ts" @@ -68,7 +68,7 @@ } if (channel_id) { const ids = new Set(channel_id instanceof Array ? channel_id : [channel_id]); - Promise.all( + await Promise.all( [...ids].map(async (id) => { const permissions = await getPermission(req.user_id, req.params.guild_id as string, id); permissions.hasThrow("VIEW_CHANNEL"); diff --git "a/src/api/routes/guilds/\043guild_id/widget.png.ts" "b/src/api/routes/guilds/\043guild_id/widget.png.ts" index c1382c9..875761e 100644 --- "a/src/api/routes/guilds/\043guild_id/widget.png.ts" +++ "b/src/api/routes/guilds/\043guild_id/widget.png.ts" @@ -83,27 +83,27 @@ switch (style) { case "shield": ctx.textAlign = "center"; - await drawText(ctx, 73, 13, "#FFFFFF", "thin 10px Verdana", presence); + drawText(ctx, 73, 13, "#FFFFFF", "thin 10px Verdana", presence); break; case "banner1": if (icon) await drawIcon(ctx, 20, 27, 50, icon); - await drawText(ctx, 83, 51, "#FFFFFF", "12px Verdana", name, 22); - await drawText(ctx, 83, 66, "#C9D2F0FF", "thin 11px Verdana", presence); + drawText(ctx, 83, 51, "#FFFFFF", "12px Verdana", name, 22); + drawText(ctx, 83, 66, "#C9D2F0FF", "thin 11px Verdana", presence); break; case "banner2": if (icon) await drawIcon(ctx, 13, 19, 36, icon); - await drawText(ctx, 62, 34, "#FFFFFF", "12px Verdana", name, 15); - await drawText(ctx, 62, 49, "#C9D2F0FF", "thin 11px Verdana", presence); + drawText(ctx, 62, 34, "#FFFFFF", "12px Verdana", name, 15); + drawText(ctx, 62, 49, "#C9D2F0FF", "thin 11px Verdana", presence); break; case "banner3": if (icon) await drawIcon(ctx, 20, 20, 50, icon); - await drawText(ctx, 83, 44, "#FFFFFF", "12px Verdana", name, 27); - await drawText(ctx, 83, 58, "#C9D2F0FF", "thin 11px Verdana", presence); + drawText(ctx, 83, 44, "#FFFFFF", "12px Verdana", name, 27); + drawText(ctx, 83, 58, "#C9D2F0FF", "thin 11px Verdana", presence); break; case "banner4": if (icon) await drawIcon(ctx, 21, 136, 50, icon); - await drawText(ctx, 84, 156, "#FFFFFF", "13px Verdana", name, 27); - await drawText(ctx, 84, 171, "#C9D2F0FF", "thin 12px Verdana", presence); + drawText(ctx, 84, 156, "#FFFFFF", "13px Verdana", name, 27); + drawText(ctx, 84, 171, "#C9D2F0FF", "thin 12px Verdana", presence); break; default: throw new HTTPError("Value must be one of ('shield', 'banner1', 'banner2', 'banner3', 'banner4').", 400); diff --git "a/src/api/routes/interactions/\043interaction_id/\043interaction_token/callback.ts" "b/src/api/routes/interactions/\043interaction_id/\043interaction_token/callback.ts" index 3734a12..8ad56ff 100644 --- "a/src/api/routes/interactions/\043interaction_id/\043interaction_token/callback.ts" +++ "b/src/api/routes/interactions/\043interaction_id/\043interaction_token/callback.ts" @@ -77,7 +77,7 @@ clearTimeout(interaction.timeout); - emitEvent({ + await emitEvent({ event: "INTERACTION_SUCCESS", user_id: interaction?.userId, data: { diff --git a/src/api/routes/interactions/index.ts b/src/api/routes/interactions/index.ts index b69f4d3..585267e 100644 --- a/src/api/routes/interactions/index.ts +++ b/src/api/routes/interactions/index.ts @@ -32,7 +32,7 @@ const interactionId = Snowflake.generate(); const interactionToken = randomBytes(24).toString("base64url"); - emitEvent({ + await emitEvent({ event: "INTERACTION_CREATE", user_id: req.user_id, data: { @@ -94,7 +94,7 @@ interactionData.message = await Message.findOneOrFail({ where: { id: body.message_id, flags: undefined }, relations: { author: true } }); } - emitEvent({ + await emitEvent({ event: "INTERACTION_CREATE", user_id: body.application_id, data: interactionData, diff --git "a/src/api/routes/users/@me/guilds/\043guild_id/settings.ts" "b/src/api/routes/users/@me/guilds/\043guild_id/settings.ts" index 083d502..72ba077 100644 --- "a/src/api/routes/users/@me/guilds/\043guild_id/settings.ts" +++ "b/src/api/routes/users/@me/guilds/\043guild_id/settings.ts" @@ -59,8 +59,9 @@ const body = req.body as UserGuildSettingsSchema; if (body.channel_overrides) { + // TODO: rewrite to a single query? for (const channel in body.channel_overrides) { - Channel.findOneOrFail({ where: { id: channel } }); + await Channel.findOneOrFail({ where: { id: channel } }); } } diff --git a/src/api/routes/users/@me/notes.ts b/src/api/routes/users/@me/notes.ts index 0b17479..3fe1682 100644 --- a/src/api/routes/users/@me/notes.ts +++ b/src/api/routes/users/@me/notes.ts @@ -79,9 +79,9 @@ }, }) ) { - Note.update({ owner: { id: owner.id }, target: { id: target.id } }, { owner, target, content: note }); + await Note.update({ owner: { id: owner.id }, target: { id: target.id } }, { owner, target, content: note }); } else { - Note.insert({ + await Note.insert({ id: Snowflake.generate(), owner, target, diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index e94fa15..a95f38c 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -115,7 +115,7 @@ } if (!ephermal) { channel.last_message_id = message.id; - channel.save(); + await channel.save(); } if (cloudAttachments && cloudAttachments.length > 0) { diff --git a/src/cdn/Server.ts b/src/cdn/Server.ts index 14bfa9f..dff7649 100644 --- a/src/cdn/Server.ts +++ b/src/cdn/Server.ts @@ -20,9 +20,7 @@ import { Attachment, Config, initDatabase, registerRoutes } from "@spacebar/util"; import { CORS, BodyParser } from "@spacebar/api"; import path from "path"; -import avatarsRoute from "./routes/avatars"; import guildProfilesRoute from "./routes/guild-profiles"; -import iconsRoute from "./routes/role-icons"; import morgan from "morgan"; import { Like } from "typeorm"; diff --git a/src/gateway/listener/listener.ts b/src/gateway/listener/listener.ts index 90f7e4b..3a7b626 100644 --- a/src/gateway/listener/listener.ts +++ b/src/gateway/listener/listener.ts @@ -240,7 +240,7 @@ break; case "GUILD_MEMBER_UPDATE": if (!this.member_events[data.user.id]) break; - this.member_events[data.user.id](); + await this.member_events[data.user.id](); break; case "RELATIONSHIP_REMOVE": case "CHANNEL_DELETE": @@ -266,7 +266,7 @@ this.events[data.user.id] = await listenEvent(data.user.id, handlePresenceUpdate.bind(this), this.listen_options); break; case "GUILD_CREATE": - Promise.all([ + await Promise.all([ ...data.channels.map(async ({ id }: { id: string }) => { this.events[id] = await listenEvent(id, consumer, listenOpts); }), diff --git a/src/gateway/start.ts b/src/gateway/start.ts index 50d69a6..79c4ca1 100644 --- a/src/gateway/start.ts +++ b/src/gateway/start.ts @@ -37,4 +37,4 @@ if (fs.existsSync("/proc/self/comm")) fs.writeFileSync("/proc/self/comm", `spacebar-gw-${cluster.worker ? cluster.worker.id : port}`); process.title = `sb-gw-${cluster.worker ? cluster.worker.id : port}`; -server.start(); +server.start().then(() => {}); diff --git a/src/util/connections/ConnectionLoader.ts b/src/util/connections/ConnectionLoader.ts index 609c53b..f75b430 100644 --- a/src/util/connections/ConnectionLoader.ts +++ b/src/util/connections/ConnectionLoader.ts @@ -28,7 +28,7 @@ export class ConnectionLoader { public static async loadConnections() { if (connectionsLoaded) return; - ConnectionConfig.init(); + await ConnectionConfig.init(); const dirs = fs.readdirSync(root).filter((x) => { try { fs.readdirSync(path.join(root, x)); @@ -38,7 +38,7 @@ } }); - dirs.forEach(async (x) => { + dirs.forEach((x) => { const modPath = path.resolve(path.join(root, x)); const mod = new (require(modPath).default)() as Connection; ConnectionStore.connections.set(mod.id, mod); @@ -54,7 +54,7 @@ if (cfg) cfg = Object.assign({}, defaults, cfg); else { cfg = defaults; - this.setConnectionConfig(id, cfg); + this.setConnectionConfig(id, cfg).catch((e) => console.error(`[Connections/ERROR] Failed to set default config for '${id}'!`, e)); } } diff --git a/src/util/util/RabbitMQ.ts b/src/util/util/RabbitMQ.ts index 288a7fa..7969bb8 100644 --- a/src/util/util/RabbitMQ.ts +++ b/src/util/util/RabbitMQ.ts @@ -102,7 +102,7 @@ this.events.emit("disconnected"); // Schedule reconnection - this.scheduleReconnect(host); + this.scheduleReconnect(host).catch((e) => console.error("[RabbitMQ] Failed to schedule reconnection:", e)); }); } diff --git a/src/webrtc/start.ts b/src/webrtc/start.ts index 14b4ce3..5419043 100644 --- a/src/webrtc/start.ts +++ b/src/webrtc/start.ts @@ -35,4 +35,4 @@ if (fs.existsSync("/proc/self/comm")) fs.writeFileSync("/proc/self/comm", `spacebar-wrtc-${cluster.worker ? cluster.worker.id : port}`); process.title = `sb-wrtc-${cluster.worker ? cluster.worker.id : port}`; -server.start(); +server.start().catch((e) => console.error("Failed to start WebRTC server:", e));