@@ -40,14 +40,14 @@ const {
40
40
} = require("./teams");
41
41
42
42
const STEP_SIZE = 100; // Resources
43
- const POOL_DEBOUNCE = 2000; // Milliseconds
44
- const POOL_MAX_DEBOUNCE = 30; // Times
43
+ const POLL_DEBOUNCE = 2000; // Milliseconds
44
+ const POLL_MAX_DEBOUNCE = 30; // Times
45
45
46
- let poolMaxDebounces = 30;
46
+ let pollMaxDebounces = 30;
47
47
48
48
const awaitPools = {
49
49
wipeAttributes: async (databaseId, collectionId, iteration = 1) => {
50
- if (iteration > poolMaxDebounces ) {
50
+ if (iteration > pollMaxDebounces ) {
51
51
return false;
52
52
}
53
53
@@ -64,12 +64,12 @@ const awaitPools = {
64
64
65
65
let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
66
66
if (steps > 1 && iteration === 1) {
67
- poolMaxDebounces *= steps;
67
+ pollMaxDebounces *= steps;
68
68
69
- log('Found a large number of attributes, increasing timeout to ' + (poolMaxDebounces * POOL_DEBOUNCE / 1000 / 60) + ' minutes')
69
+ log('Found a large number of attributes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
70
70
}
71
71
72
- await new Promise(resolve => setTimeout(resolve, POOL_DEBOUNCE ));
72
+ await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE ));
73
73
74
74
return await awaitPools.wipeAttributes(
75
75
databaseId,
@@ -78,7 +78,7 @@ const awaitPools = {
78
78
);
79
79
},
80
80
wipeIndexes: async (databaseId, collectionId, iteration = 1) => {
81
- if (iteration > poolMaxDebounces ) {
81
+ if (iteration > pollMaxDebounces ) {
82
82
return false;
83
83
}
84
84
@@ -95,12 +95,12 @@ const awaitPools = {
95
95
96
96
let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
97
97
if (steps > 1 && iteration === 1) {
98
- poolMaxDebounces *= steps;
98
+ pollMaxDebounces *= steps;
99
99
100
- log('Found a large number of indexes, increasing timeout to ' + (poolMaxDebounces * POOL_DEBOUNCE / 1000 / 60) + ' minutes')
100
+ log('Found a large number of indexes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
101
101
}
102
102
103
- await new Promise(resolve => setTimeout(resolve, POOL_DEBOUNCE ));
103
+ await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE ));
104
104
105
105
return await awaitPools.wipeIndexes(
106
106
databaseId,
@@ -109,7 +109,7 @@ const awaitPools = {
109
109
);
110
110
},
111
111
wipeVariables: async (functionId, iteration = 1) => {
112
- if (iteration > poolMaxDebounces ) {
112
+ if (iteration > pollMaxDebounces ) {
113
113
return false;
114
114
}
115
115
@@ -125,28 +125,28 @@ const awaitPools = {
125
125
126
126
let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
127
127
if (steps > 1 && iteration === 1) {
128
- poolMaxDebounces *= steps;
128
+ pollMaxDebounces *= steps;
129
129
130
- log('Found a large number of variables, increasing timeout to ' + (poolMaxDebounces * POOL_DEBOUNCE / 1000 / 60) + ' minutes')
130
+ log('Found a large number of variables, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
131
131
}
132
132
133
- await new Promise(resolve => setTimeout(resolve, POOL_DEBOUNCE ));
133
+ await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE ));
134
134
135
135
return await awaitPools.wipeVariables(
136
136
functionId,
137
137
iteration + 1
138
138
);
139
139
},
140
140
expectAttributes: async (databaseId, collectionId, attributeKeys, iteration = 1) => {
141
- if (iteration > poolMaxDebounces ) {
141
+ if (iteration > pollMaxDebounces ) {
142
142
return false;
143
143
}
144
144
145
145
let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
146
146
if (steps > 1 && iteration === 1) {
147
- poolMaxDebounces *= steps;
147
+ pollMaxDebounces *= steps;
148
148
149
- log('Creating a large number of attributes, increasing timeout to ' + (poolMaxDebounces * POOL_DEBOUNCE / 1000 / 60) + ' minutes')
149
+ log('Creating a large number of attributes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
150
150
}
151
151
152
152
const { attributes } = await paginate(databasesListAttributes, {
@@ -173,7 +173,7 @@ const awaitPools = {
173
173
return true;
174
174
}
175
175
176
- await new Promise(resolve => setTimeout(resolve, POOL_DEBOUNCE ));
176
+ await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE ));
177
177
178
178
return await awaitPools.expectAttributes(
179
179
databaseId,
@@ -183,15 +183,15 @@ const awaitPools = {
183
183
);
184
184
},
185
185
expectIndexes: async (databaseId, collectionId, indexKeys, iteration = 1) => {
186
- if (iteration > poolMaxDebounces ) {
186
+ if (iteration > pollMaxDebounces ) {
187
187
return false;
188
188
}
189
189
190
190
let steps = Math.max(1, Math.ceil(indexKeys.length / STEP_SIZE));
191
191
if (steps > 1 && iteration === 1) {
192
- poolMaxDebounces *= steps;
192
+ pollMaxDebounces *= steps;
193
193
194
- log('Creating a large number of indexes, increasing timeout to ' + (poolMaxDebounces * POOL_DEBOUNCE / 1000 / 60) + ' minutes')
194
+ log('Creating a large number of indexes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
195
195
}
196
196
197
197
const { indexes } = await paginate(databasesListIndexes, {
@@ -218,7 +218,7 @@ const awaitPools = {
218
218
return true;
219
219
}
220
220
221
- await new Promise(resolve => setTimeout(resolve, POOL_DEBOUNCE ));
221
+ await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE ));
222
222
223
223
return await awaitPools.expectIndexes(
224
224
databaseId,
@@ -458,11 +458,11 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
458
458
try {
459
459
const deploymentId = response['$id'];
460
460
updaterRow.update({ status: 'Deploying', end: 'Checking deployment status...' })
461
- let pool_checks = 0;
461
+ let pollChecks = 0;
462
462
463
463
while (true) {
464
- if (pool_checks >= POOL_MAX_DEBOUNCE ) {
465
- updaterRow.update({ end: 'Deployment takes too long; check the console' })
464
+ if (pollChecks >= POLL_MAX_DEBOUNCE ) {
465
+ updaterRow.update({ end: 'Deployment is taking too long. Please check the console for more details. ' })
466
466
break;
467
467
}
468
468
@@ -480,18 +480,18 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
480
480
481
481
break;
482
482
} else if (status === 'failed') {
483
- updaterRow.fail({ errorMessage: 'failed to deploy' });
483
+ updaterRow.fail({ errorMessage: 'Failed to deploy. ' });
484
484
485
485
break;
486
486
} else {
487
- updaterRow.update({ status: 'Deploying', end: `current status: ${status}` })
487
+ updaterRow.update({ status: 'Deploying', end: `Current status: ${status}` })
488
488
}
489
489
490
- pool_checks ++;
491
- await new Promise(resolve => setTimeout(resolve, POOL_DEBOUNCE ));
490
+ pollChecks ++;
491
+ await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE ));
492
492
}
493
493
} catch (e) {
494
- updaterRow.fail({ errorMessage: e.message ?? 'General error occurs please try again' })
494
+ updaterRow.fail({ errorMessage: e.message ?? 'Unknown error occurred. Please try again' })
495
495
}
496
496
}
497
497
0 commit comments