Fixes in reports (generating a CSV).
Added caching of generated images in mosaico handler. Various other fixes.
This commit is contained in:
parent
055c4c6b51
commit
66702b5edc
39 changed files with 545 additions and 278 deletions
26
server/lib/synchronized.js
Normal file
26
server/lib/synchronized.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
// This implements a simple wrapper around an async function that prevents concurrent execution of the function from two asynchronous chains
|
||||
// It enforces that the running execution has to complete first before another one is started.
|
||||
function synchronized(asyncFn) {
|
||||
let ensurePromise = null;
|
||||
|
||||
return async (...args) => {
|
||||
while (ensurePromise) {
|
||||
try {
|
||||
await ensurePromise;
|
||||
} catch (err) {
|
||||
}
|
||||
}
|
||||
|
||||
ensurePromise = asyncFn(...args);
|
||||
|
||||
try {
|
||||
return await ensurePromise;
|
||||
} finally {
|
||||
ensurePromise = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = synchronized;
|
Loading…
Add table
Add a link
Reference in a new issue