Skip to content

Commit a17475a

Browse files
committed
feat: destroy socket in finally block
1 parent 362eee4 commit a17475a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

electron/main/sge/sge.login.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,15 @@ export async function loginCharacter(options: {
7777
// Select character to play and get back game credentials
7878
const credentials = await getGameCredentials({ socket, characterName });
7979

80-
socket.end();
81-
8280
return {
8381
subscription,
8482
credentials,
8583
};
8684
} catch (error) {
8785
logger.error('error logging in', { error });
88-
socket.destroy();
8986
throw error;
87+
} finally {
88+
socket.destroySoon();
9089
}
9190
}
9291

@@ -135,13 +134,12 @@ export async function listCharacters(options: {
135134
// Retrieve list of characters available to the account
136135
const characters = await listAvailableCharacters({ socket });
137136

138-
socket.end();
139-
140137
return characters;
141138
} catch (error) {
142139
logger.error('error listing characters', { error });
143-
socket.destroy();
144140
throw error;
141+
} finally {
142+
socket.destroySoon();
145143
}
146144
}
147145

0 commit comments

Comments
 (0)