0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-12 21:30:43 -05:00

Wrap saving in try-catch so that if an error occurs the server will continue to save other profiles

This commit is contained in:
Archangel 2025-01-31 01:17:06 +01:00
parent 4595c29c15
commit 7f2f270534

View File

@ -72,12 +72,19 @@ export class SaveServer {
*/
public async save(): Promise<void> {
const timer = new Timer();
let savedProfiles = 0;
for (const [sessionId] of this.profiles) {
await this.saveProfile(sessionId);
try {
await this.saveProfile(sessionId);
savedProfiles++;
} catch (error) {
this.logger.error(`Could not save profile ${sessionId} | ${error}`);
}
}
const profileCount = this.profiles.size;
this.logger.debug(
`Saving ${profileCount} profile${profileCount > 1 ? "s" : ""} took ${timer.getTime("ms")}ms`,
`Saving ${savedProfiles} profile${savedProfiles > 1 ? "s" : ""} took ${timer.getTime("ms")}ms`,
false,
);
}