electron-main: Immediatelly set the eventIndex variable to null when closing.

The react-sdk doesn't await the closing of the event index, this is done
so because of limitations in the lifecycle module. This wasn't a problem
since we used to just set the eventIndex variable to null. Nowadays we
wait for Tantivy to shutdown using a close() method on the index.

To avoid this being called multiple times while we're already closing the
index set the eventIndex variable to null before awaiting.

This fixes https://github.com/vector-im/riot-web/issues/12838.
This commit is contained in:
Damir Jelić 2020-03-24 14:16:54 +01:00
parent 39656bb622
commit 1e05af203c

View file

@ -394,14 +394,16 @@ ipcMain.on('seshat', async function(ev, payload) {
case 'closeEventIndex': case 'closeEventIndex':
if (eventIndex !== null) { if (eventIndex !== null) {
let index = eventIndex;
eventIndex = null;
try { try {
await eventIndex.shutdown(); await index.shutdown();
} catch (e) { } catch (e) {
sendError(payload.id, e); sendError(payload.id, e);
return; return;
} }
} }
eventIndex = null;
break; break;
case 'deleteEventIndex': case 'deleteEventIndex':