@@ -152,7 +152,7 @@ const awaitPools = {
152
152
iteration + 1
153
153
);
154
154
},
155
- wipeVariables : async (functionId, iteration = 1) => {
155
+ wipeFunctionVariables : async (functionId, iteration = 1) => {
156
156
if (iteration > pollMaxDebounces) {
157
157
return false;
158
158
}
@@ -178,11 +178,42 @@ const awaitPools = {
178
178
179
179
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
180
180
181
- return await awaitPools.wipeVariables (
181
+ return await awaitPools.wipeFunctionVariables (
182
182
functionId,
183
183
iteration + 1
184
184
);
185
185
},
186
+ wipeSiteVariables: async (siteId, iteration = 1) => {
187
+ if (iteration > pollMaxDebounces) {
188
+ return false;
189
+ }
190
+
191
+ const { total } = await sitesListVariables({
192
+ siteId,
193
+ queries: ['limit(1)'],
194
+ parseOutput: false
195
+ });
196
+
197
+ if (total === 0) {
198
+ return true;
199
+ }
200
+
201
+ if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
202
+ let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
203
+ if (steps > 1 && iteration === 1) {
204
+ pollMaxDebounces *= steps;
205
+
206
+ log('Found a large number of variables, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
207
+ }
208
+ }
209
+
210
+ await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
211
+
212
+ return await awaitPools.wipeSiteVariables(
213
+ siteId,
214
+ iteration + 1
215
+ );
216
+ },
186
217
deleteAttributes: async (databaseId, collectionId, attributeKeys, iteration = 1) => {
187
218
if (iteration > pollMaxDebounces) {
188
219
return false;
@@ -1231,7 +1262,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1231
1262
});
1232
1263
}));
1233
1264
1234
- let result = await awaitPools.wipeVariables (site['$id']);
1265
+ let result = await awaitPools.wipeSiteVariables (site['$id']);
1235
1266
if (!result) {
1236
1267
updaterRow.fail({ errorMessage: `Variable deletion timed out.` })
1237
1268
return;
@@ -1253,7 +1284,8 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1253
1284
siteId: site['$id'],
1254
1285
key: variable.key,
1255
1286
value: variable.value,
1256
- parseOutput: false
1287
+ parseOutput: false,
1288
+ secret: false
1257
1289
});
1258
1290
}));
1259
1291
}
@@ -1557,7 +1589,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1557
1589
});
1558
1590
}));
1559
1591
1560
- let result = await awaitPools.wipeVariables (func['$id']);
1592
+ let result = await awaitPools.wipeFunctionVariables (func['$id']);
1561
1593
if (!result) {
1562
1594
updaterRow.fail({ errorMessage: `Variable deletion timed out.` })
1563
1595
return;
0 commit comments