mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Switch webhook secret cache from LRU to TTL so that unsubscribing can drain the queue
Summary: Helps with cases such as https://grist.slack.com/archives/C02EGJ1FUCV/p1652196111066649?thread_ts=1651656433.171889&cid=C02EGJ1FUCV When a user unsubscribes from a webhook, the secret URL is deleted from the database, but as long as the doc was open it would continue retrying pending requests still in the queue for a long time, using the locally cached value without noticing the effect of unsubscribing. This change allows unsubscribing to have an effect more quickly so that problematic events can be removed from the queue. Test Plan: existing tests Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3430
This commit is contained in:
parent
f93b4fd3bc
commit
cbdbe3f605
@ -1,5 +1,6 @@
|
||||
import {LocalActionBundle} from 'app/common/ActionBundle';
|
||||
import {ActionSummary, TableDelta} from 'app/common/ActionSummary';
|
||||
import {MapWithTTL} from 'app/common/AsyncCreate';
|
||||
import {delay} from 'app/common/delay';
|
||||
import {fromTableDataAction, RowRecord, TableColValues, TableDataAction} from 'app/common/DocActions';
|
||||
import {StringUnion} from 'app/common/StringUnion';
|
||||
@ -11,7 +12,6 @@ import {makeExceptionalDocSession} from 'app/server/lib/DocSession';
|
||||
import * as log from 'app/server/lib/log';
|
||||
import {promisifyAll} from 'bluebird';
|
||||
import * as _ from 'lodash';
|
||||
import * as LRUCache from 'lru-cache';
|
||||
import fetch from 'node-fetch';
|
||||
import {createClient, Multi, RedisClient} from 'redis';
|
||||
|
||||
@ -69,6 +69,8 @@ interface Task {
|
||||
|
||||
const MAX_QUEUE_SIZE = 1000;
|
||||
|
||||
const WEBHOOK_CACHE_TTL = 10000;
|
||||
|
||||
// Processes triggers for records changed as described in action bundles.
|
||||
// initiating webhooks and automations.
|
||||
// The interesting stuff starts in the handle() method.
|
||||
@ -87,7 +89,7 @@ export class DocTriggers {
|
||||
private _webHookEventQueue: WebHookEvent[] = [];
|
||||
|
||||
// DB cache for webhook secrets
|
||||
private _webhookCache = new LRUCache<string, WebHookSecret>({max: 1000});
|
||||
private _webhookCache = new MapWithTTL<string, WebHookSecret>(WEBHOOK_CACHE_TTL);
|
||||
|
||||
// Set to true by shutdown().
|
||||
// Indicates that loops (especially for sending requests) should stop.
|
||||
|
Loading…
Reference in New Issue
Block a user