Skip to content

Commit b43e6bb

Browse files
committed
Catch role cache clear rejection on role deletion
1 parent 89b1b6a commit b43e6bb

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/rest.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var triggers = require('./triggers');
1515
const Auth = require('./Auth');
1616
const { enforceRoleSecurity } = require('./SharedRest');
1717
const { createSanitizedError } = require('./Error');
18+
const logger = require('./logger').logger;
1819

1920
function checkTriggers(className, config, types) {
2021
return types.some(triggerType => {
@@ -248,7 +249,12 @@ function del(config, auth, className, objectId, context) {
248249
// of its children, and the whole role cache is cleared rather than one
249250
// user's entry.
250251
if (className === '_Role') {
251-
config.cacheController.role.clear();
252+
// Issued without being awaited so a cache outage cannot fail a delete
253+
// that already committed, but the rejection is caught so it does not
254+
// surface as an unhandled rejection.
255+
config.cacheController.role
256+
.clear()
257+
.catch(e => logger.error('Could not clear role cache after role deletion', { error: e }));
252258
if (config.liveQueryController) {
253259
config.liveQueryController.clearCachedRoles(auth.user);
254260
}

0 commit comments

Comments
 (0)