Stickers
Co-authored-by: scott@signal.org Co-authored-by: ken@signal.org
This commit is contained in:
parent
8c8856785b
commit
29de50c12a
100 changed files with 7572 additions and 693 deletions
|
@ -1,4 +1,5 @@
|
|||
const electron = require('electron');
|
||||
const Queue = require('p-queue');
|
||||
const sql = require('./sql');
|
||||
const { remove: removeUserConfig } = require('./user_config');
|
||||
const { remove: removeEphemeralConfig } = require('./ephemeral_config');
|
||||
|
@ -14,6 +15,8 @@ let initialized = false;
|
|||
const SQL_CHANNEL_KEY = 'sql-channel';
|
||||
const ERASE_SQL_KEY = 'erase-sql-key';
|
||||
|
||||
const queue = new Queue({ concurrency: 1 });
|
||||
|
||||
function initialize() {
|
||||
if (initialized) {
|
||||
throw new Error('sqlChannels: already initialized!');
|
||||
|
@ -29,7 +32,10 @@ function initialize() {
|
|||
);
|
||||
}
|
||||
|
||||
const result = await fn(...args);
|
||||
// Note: we queue here to keep multi-query operations atomic. Without it, any
|
||||
// multistage data operation (even within a BEGIN/COMMIT) can become interleaved,
|
||||
// since all requests share one database connection.
|
||||
const result = await queue.add(() => fn(...args));
|
||||
event.sender.send(`${SQL_CHANNEL_KEY}-done`, jobId, null, result);
|
||||
} catch (error) {
|
||||
const errorForDisplay = error && error.stack ? error.stack : error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue