@adobe/helix-deploy 6.2.14 → 6.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [6.2.15](https://github.com/adobe/helix-deploy/compare/v6.2.14...v6.2.15) (2022-03-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **gateway:** clean up old and outdated tokens when token dictionary is full ([f5adc57](https://github.com/adobe/helix-deploy/commit/f5adc5757595311192d724235fa83b9db703acf9))
7
+
1
8
  ## [6.2.14](https://github.com/adobe/helix-deploy/compare/v6.2.13...v6.2.14) (2022-03-05)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-deploy",
3
- "version": "6.2.14",
3
+ "version": "6.2.15",
4
4
  "description": "Library and Commandline Tools to build and deploy OpenWhisk Actions",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/adobe/helix-deploy#readme",
@@ -87,7 +87,23 @@ export default class FastlyGateway {
87
87
  if (packageparams.length !== 0) {
88
88
  await this._fastly.bulkUpdateDictItems(undefined, 'packageparams', ...packageparams);
89
89
  }
90
- await this._fastly.updateDictItem(undefined, 'tokens', this.cfg.packageToken, `${Math.floor(Date.now() / 1000) + (365 * 24 * 3600)}`);
90
+
91
+ try {
92
+ await this._fastly.updateDictItem(undefined, 'tokens', this.cfg.packageToken, `${Math.floor(Date.now() / 1000) + (365 * 24 * 3600)}`);
93
+ } catch (fe) {
94
+ if (fe.message.match('Exceeding max_dictionary_items')) {
95
+ const dictinfo = await this._fastly.readDictItems(undefined, 'tokens');
96
+ const items = dictinfo.data;
97
+ const outdated = items
98
+ .filter((item) => parseInt(item.item_value, 10) < new Date().getTime() / 1000);
99
+ const olds = items.slice(0, 5);
100
+ // cleanup all old and outdated tokens
101
+ await Promise.all([...outdated, ...olds].map((item) => this._fastly.deleteDictItem(undefined, 'tokens', item.item_key)));
102
+ // try again
103
+ await this._fastly.updateDictItem(undefined, 'tokens', this.cfg.packageToken, `${Math.floor(Date.now() / 1000) + (365 * 24 * 3600)}`);
104
+ }
105
+ }
106
+
91
107
  this._fastly.discard();
92
108
  this.log.info(chalk`{green ok:} updating app (package) parameters on Fastly gateway.`);
93
109
  }