diff --git a/nix/testVm/vm.nix b/nix/testVm/vm.nix
index eccd12b2..0c61aa83 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 86d502e2..564450ee 100644
--- a/scripts/openapi.js
+++ b/scripts/openapi.js
@@ -256,4 +256,4 @@ async function main() {
);
}
-main();
+main().then(() => {});
diff --git a/scripts/schema.js b/scripts/schema.js
index 67c5563c..60398472 100644
--- a/scripts/schema.js
+++ b/scripts/schema.js
@@ -380,4 +380,4 @@ function columnizedObjectDiff(a, b, trackEqual = false) {
return diffs;
}
-main();
+main().then(() => {});
diff --git a/scripts/stress/login.js b/scripts/stress/login.js
index 830d6a48..9009e56d 100644
--- a/scripts/stress/login.js
+++ b/scripts/stress/login.js
@@ -13,4 +13,4 @@ async function main() {
console.log((await ret.json()).token);
}
-main();
+main().then(() => {});
diff --git a/scripts/stress/users.js b/scripts/stress/users.js
index 2fc41eae..8135368d 100644
--- a/scripts/stress/users.js
+++ b/scripts/stress/users.js
@@ -34,9 +34,9 @@ async function main() {
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 58c18029..d0fc38f0 100644
--- a/scripts/syncronise.js
+++ b/scripts/syncronise.js
@@ -34,5 +34,5 @@ const { initDatabase } = require("..");
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 6a61d3cb..f6c38398 100644
--- a/src/api/Server.ts
+++ b/src/api/Server.ts
@@ -200,7 +200,7 @@ export class SpacebarServer extends Server {
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/#application_id/bot/index.ts b/src/api/routes/applications/#application_id/bot/index.ts
index 47b8a729..a5eb3127 100644
--- a/src/api/routes/applications/#application_id/bot/index.ts
+++ b/src/api/routes/applications/#application_id/bot/index.ts
@@ -122,7 +122,7 @@ router.patch(
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/#channel_id/messages/#message_id/index.ts b/src/api/routes/channels/#channel_id/messages/#message_id/index.ts
index c0569124..96ff98e1 100644
--- a/src/api/routes/channels/#channel_id/messages/#message_id/index.ts
+++ b/src/api/routes/channels/#channel_id/messages/#message_id/index.ts
@@ -113,7 +113,7 @@ router.patch(
} 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 @@ router.delete(
});
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/#channel_id/messages/#message_id/threads.ts b/src/api/routes/channels/#channel_id/messages/#message_id/threads.ts
index eb375e5d..7bb119df 100644
--- a/src/api/routes/channels/#channel_id/messages/#message_id/threads.ts
+++ b/src/api/routes/channels/#channel_id/messages/#message_id/threads.ts
@@ -89,7 +89,7 @@ router.post(
},
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/#channel_id/threads.ts b/src/api/routes/channels/#channel_id/threads.ts
index 9d10cb17..22b29e52 100644
--- a/src/api/routes/channels/#channel_id/threads.ts
+++ b/src/api/routes/channels/#channel_id/threads.ts
@@ -126,7 +126,7 @@ router.post(
}),
]);
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/#connection_name/authorize.ts b/src/api/routes/connections/#connection_name/authorize.ts
index ca56bbe3..b74fd861 100644
--- a/src/api/routes/connections/#connection_name/authorize.ts
+++ b/src/api/routes/connections/#connection_name/authorize.ts
@@ -43,7 +43,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
});
res.json({
- url: await connection.getAuthorizationUrl(req.user_id),
+ url: connection.getAuthorizationUrl(req.user_id),
});
});
diff --git a/src/api/routes/connections/#connection_name/callback.ts b/src/api/routes/connections/#connection_name/callback.ts
index 2f6a25a0..7fc72530 100644
--- a/src/api/routes/connections/#connection_name/callback.ts
+++ b/src/api/routes/connections/#connection_name/callback.ts
@@ -49,7 +49,7 @@ router.post("/", route({ requestBody: "ConnectionCallbackSchema" }), async (req:
// 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/#guild_id/messages/search.ts b/src/api/routes/guilds/#guild_id/messages/search.ts
index eb9ecd6d..601d39d6 100644
--- a/src/api/routes/guilds/#guild_id/messages/search.ts
+++ b/src/api/routes/guilds/#guild_id/messages/search.ts
@@ -68,7 +68,7 @@ router.get(
}
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/#guild_id/widget.png.ts b/src/api/routes/guilds/#guild_id/widget.png.ts
index c1382c90..875761e6 100644
--- a/src/api/routes/guilds/#guild_id/widget.png.ts
+++ b/src/api/routes/guilds/#guild_id/widget.png.ts
@@ -83,27 +83,27 @@ router.get(
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/#interaction_id/#interaction_token/callback.ts b/src/api/routes/interactions/#interaction_id/#interaction_token/callback.ts
index 3734a12e..8ad56ff9 100644
--- a/src/api/routes/interactions/#interaction_id/#interaction_token/callback.ts
+++ b/src/api/routes/interactions/#interaction_id/#interaction_token/callback.ts
@@ -77,7 +77,7 @@ router.post("/", route({}), async (req: Request, res: Response) => {
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 b69f4d37..585267e9 100644
--- a/src/api/routes/interactions/index.ts
+++ b/src/api/routes/interactions/index.ts
@@ -32,7 +32,7 @@ router.post("/", route({}), async (req: Request, res: Response) => {
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 @@ router.post("/", route({}), async (req: Request, res: Response) => {
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/#guild_id/settings.ts b/src/api/routes/users/@me/guilds/#guild_id/settings.ts
index 083d5024..72ba0773 100644
--- a/src/api/routes/users/@me/guilds/#guild_id/settings.ts
+++ b/src/api/routes/users/@me/guilds/#guild_id/settings.ts
@@ -59,8 +59,9 @@ router.patch(
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 0b174791..3fe1682e 100644
--- a/src/api/routes/users/@me/notes.ts
+++ b/src/api/routes/users/@me/notes.ts
@@ -79,9 +79,9 @@ router.put(
},
})
) {
- 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 e94fa152..a95f38c0 100644
--- a/src/api/util/handlers/Message.ts
+++ b/src/api/util/handlers/Message.ts
@@ -115,7 +115,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
}
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 14bfa9f9..dff76494 100644
--- a/src/cdn/Server.ts
+++ b/src/cdn/Server.ts
@@ -20,9 +20,7 @@ import { Server, ServerOptions } from "lambert-server";
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 90f7e4b1..3a7b626c 100644
--- a/src/gateway/listener/listener.ts
+++ b/src/gateway/listener/listener.ts
@@ -240,7 +240,7 @@ async function consume(this: WebSocket, opts: EventOpts) {
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 @@ async function consume(this: WebSocket, opts: EventOpts) {
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 50d69a61..79c4ca19 100644
--- a/src/gateway/start.ts
+++ b/src/gateway/start.ts
@@ -37,4 +37,4 @@ const server = new Server({
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 609c53b0..f75b430f 100644
--- a/src/util/connections/ConnectionLoader.ts
+++ b/src/util/connections/ConnectionLoader.ts
@@ -28,7 +28,7 @@ const connectionsLoaded = false;
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 @@ export class ConnectionLoader {
}
});
- 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 @@ export class ConnectionLoader {
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 288a7fa9..7969bb8b 100644
--- a/src/util/util/RabbitMQ.ts
+++ b/src/util/util/RabbitMQ.ts
@@ -102,7 +102,7 @@ export class RabbitMQ {
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 14b4ce3a..54190436 100644
--- a/src/webrtc/start.ts
+++ b/src/webrtc/start.ts
@@ -35,4 +35,4 @@ const server = new Server({
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));
|