const doAfterUnlock = async (session, func, ...args) => {
while (session.isBlock) {
// eslint-disable-next-line no-await-in-loop
await delay(1); // free event loop
}
try {
session.isBlock = true;
await func(...args);
} catch (e) {
console.error(e);
} finally {
session.isBlock = false;
}
};