@reventlessdev/reventless-seed-aws 1.0.0-alpha.12 → 1.0.0-alpha.13

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/bs/.compiler.log +2 -2
  3. package/lib/bs/compiler-info.json +1 -1
  4. package/lib/bs/src/ReventlessSeedAws_Quiesce.ast +0 -0
  5. package/lib/bs/src/ReventlessSeedAws_Quiesce.cmi +0 -0
  6. package/lib/bs/src/ReventlessSeedAws_Quiesce.cmj +0 -0
  7. package/lib/bs/src/ReventlessSeedAws_Quiesce.cmt +0 -0
  8. package/lib/bs/src/ReventlessSeedAws_Quiesce.res +287 -0
  9. package/lib/bs/src/ReventlessSeedAws_Quiesce.res.mjs +205 -0
  10. package/lib/bs/src/ReventlessSeedAws_Reconcile.ast +0 -0
  11. package/lib/bs/src/ReventlessSeedAws_Reconcile.cmi +0 -0
  12. package/lib/bs/src/ReventlessSeedAws_Reconcile.cmt +0 -0
  13. package/lib/bs/src/ReventlessSeedAws_Reconcile.res +2 -6
  14. package/lib/bs/src/ReventlessSeedAws_Reconcile.res.mjs +2 -2
  15. package/lib/bs/src/ReventlessSeedAws_Reset.ast +0 -0
  16. package/lib/bs/src/ReventlessSeedAws_Reset.cmi +0 -0
  17. package/lib/bs/src/ReventlessSeedAws_Reset.cmj +0 -0
  18. package/lib/bs/src/ReventlessSeedAws_Reset.cmt +0 -0
  19. package/lib/bs/src/ReventlessSeedAws_Reset.res +223 -73
  20. package/lib/bs/src/ReventlessSeedAws_Reset.res.mjs +212 -82
  21. package/lib/bs/tests/ObjectStoreReconcileTest.cmi +0 -0
  22. package/lib/bs/tests/ObjectStoreReconcileTest.cmt +0 -0
  23. package/lib/bs/tests/ObjectStoreResetTest.cmi +0 -0
  24. package/lib/bs/tests/ObjectStoreResetTest.cmt +0 -0
  25. package/lib/bs/tests/QuiesceResetTest.ast +0 -0
  26. package/lib/bs/tests/QuiesceResetTest.cmi +0 -0
  27. package/lib/bs/tests/QuiesceResetTest.cmj +0 -0
  28. package/lib/bs/tests/QuiesceResetTest.cmt +0 -0
  29. package/lib/bs/tests/QuiesceResetTest.res +133 -0
  30. package/lib/bs/tests/QuiesceResetTest.res.mjs +141 -0
  31. package/lib/ocaml/.compiler.log +2 -2
  32. package/lib/ocaml/ObjectStoreReconcileTest.cmi +0 -0
  33. package/lib/ocaml/ObjectStoreReconcileTest.cmt +0 -0
  34. package/lib/ocaml/ObjectStoreResetTest.cmi +0 -0
  35. package/lib/ocaml/ObjectStoreResetTest.cmt +0 -0
  36. package/lib/ocaml/QuiesceResetTest.ast +0 -0
  37. package/lib/ocaml/QuiesceResetTest.cmi +0 -0
  38. package/lib/ocaml/QuiesceResetTest.cmj +0 -0
  39. package/lib/ocaml/QuiesceResetTest.cmt +0 -0
  40. package/lib/ocaml/QuiesceResetTest.res +133 -0
  41. package/lib/ocaml/ReventlessSeedAws_Quiesce.ast +0 -0
  42. package/lib/ocaml/ReventlessSeedAws_Quiesce.cmi +0 -0
  43. package/lib/ocaml/ReventlessSeedAws_Quiesce.cmj +0 -0
  44. package/lib/ocaml/ReventlessSeedAws_Quiesce.cmt +0 -0
  45. package/lib/ocaml/ReventlessSeedAws_Quiesce.res +287 -0
  46. package/lib/ocaml/ReventlessSeedAws_Reconcile.ast +0 -0
  47. package/lib/ocaml/ReventlessSeedAws_Reconcile.cmi +0 -0
  48. package/lib/ocaml/ReventlessSeedAws_Reconcile.cmt +0 -0
  49. package/lib/ocaml/ReventlessSeedAws_Reconcile.res +2 -6
  50. package/lib/ocaml/ReventlessSeedAws_Reset.ast +0 -0
  51. package/lib/ocaml/ReventlessSeedAws_Reset.cmi +0 -0
  52. package/lib/ocaml/ReventlessSeedAws_Reset.cmj +0 -0
  53. package/lib/ocaml/ReventlessSeedAws_Reset.cmt +0 -0
  54. package/lib/ocaml/ReventlessSeedAws_Reset.res +223 -73
  55. package/package.json +2 -2
  56. package/src/ReventlessSeedAws_Quiesce.res +287 -0
  57. package/src/ReventlessSeedAws_Quiesce.res.mjs +205 -0
  58. package/src/ReventlessSeedAws_Reconcile.res +2 -6
  59. package/src/ReventlessSeedAws_Reconcile.res.mjs +2 -2
  60. package/src/ReventlessSeedAws_Reset.res +223 -73
  61. package/src/ReventlessSeedAws_Reset.res.mjs +212 -82
  62. package/tests/QuiesceResetTest.res +133 -0
  63. package/tests/QuiesceResetTest.res.mjs +141 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 1.0.0-alpha.13 (2026-08-09)
7
+
8
+ ### Bug Fixes
9
+
10
+ * **seed-aws:** hold and recycle a stack's runtimes so a reset stays empty ([4baaa38](https://github.com/ReventlessDev/reventless-core/commit/4baaa3827ef30a0adccdef5d2bccc688e7b6686f))
11
+
12
+
6
13
  # 1.0.0-alpha.12 (2026-08-05)
7
14
 
8
15
  **Note:** Version bump only for package @reventlessdev/reventless-seed-aws
@@ -1,2 +1,2 @@
1
- #Start(1785972973754)
2
- #Done(1785972973793)
1
+ #Start(1786243797857)
2
+ #Done(1786243797920)
@@ -4,5 +4,5 @@
4
4
  "bsc_hash": "75e3a59c95cc953608fd3dd6ea6ed68141bba4414a20a52f114261b8a48385fa",
5
5
  "rescript_config_hash": "c18a0067c363fd1290f6e7f6fe6212d2e16e201c1702fac667962047f88ed468",
6
6
  "runtime_path": "/home/runner/work/reventless-core/reventless-core/node_modules/@rescript/runtime",
7
- "generated_at": "1785972973799"
7
+ "generated_at": "1786243797925"
8
8
  }
@@ -0,0 +1,287 @@
1
+ // Taking a deployed stack's runtimes out of service for the length of a wipe,
2
+ // and putting them back exactly as they were.
3
+ //
4
+ // Why a wipe needs this at all: a truncate is not durable while the runtimes
5
+ // that own the data are running. A slice runtime keeps its TODO list in a
6
+ // module-level dict for the lifetime of its execution environment and re-saves
7
+ // every row it holds at the end of each invocation — including the scheduled
8
+ // sweep, which carries no events. Emptying the table under a warm container
9
+ // therefore succeeds and is then undone, byte for byte, by the next sweep: the
10
+ // rows are not recomputed from anything, so their ids and timestamps come back
11
+ // identical. Emptying the upstream stores first does not help, because nothing
12
+ // upstream is read.
13
+ //
14
+ // The answer is to remove the contention rather than to outrun it, which takes
15
+ // two distinct steps, in this order:
16
+ //
17
+ // 1. HOLD — reserve 0 concurrency on every function in scope, so no new
18
+ // invocation can start while the wipe and its verification run. This alone
19
+ // is not enough: a reservation stops invocations, it does not discard the
20
+ // execution environment that holds the state.
21
+ // 2. RECYCLE — change each function's configuration once. A configuration
22
+ // change is the documented way to make Lambda discard existing execution
23
+ // environments, so whatever a warm container was holding is gone before it
24
+ // can be invoked again. Done while still held, so the container that
25
+ // eventually replaces it starts from the emptied store.
26
+ //
27
+ // The recycle is a round trip — a marker variable added, then the original map
28
+ // put back — so the function ends the run byte-identical to how it started and
29
+ // `pulumi preview` reports no drift. The second update recycles again, which is
30
+ // harmless: it happens while the hold is still on and the store is already
31
+ // empty.
32
+ //
33
+ // Everything acquired here is released on the failure path as well as the
34
+ // success path, and the release never throws: a reset that aborted mid-wipe
35
+ // must still hand the stack back. Release failures come back as warnings for
36
+ // the caller to print, because a function left at zero concurrency is a stack
37
+ // left switched off, and that has to be said out loud rather than raised as one
38
+ // more exception on top of whatever already went wrong.
39
+
40
+ module Lambda = AwsSdk.Lambda
41
+
42
+ /** The variable a recycle adds and then removes. Named for what it is, so an
43
+ operator who finds one left behind by a killed run knows it is inert and can
44
+ be deleted (or left for the next `pulumi up` to remove). */
45
+ let markerKey = "REVENTLESS_RESET_RECYCLE"
46
+
47
+ /** What one function looked like before the reset touched it. */
48
+ type held = {
49
+ functionName: string,
50
+ /** `None` = the function had no reservation at all. That is a different state
51
+ from a reservation of 0, and restoring it needs
52
+ `DeleteFunctionConcurrency` rather than a put. */
53
+ priorReserved: option<int>,
54
+ /** The variable map as it was, flattened: a function with no `Environment`
55
+ block at all reads as an empty map and is restored to an empty map. */
56
+ priorVariables: dict<string>,
57
+ }
58
+
59
+ /** The Lambda control plane is rate-limited well below the data plane, and a
60
+ reset touches every function in a project at once. Six at a time keeps a
61
+ forty-function stack under a minute per pass without risking a throttle. */
62
+ let concurrency = 6
63
+
64
+ let mapBounded = async (items: array<'a>, ~limit: int, f: 'a => promise<'b>): array<'b> => {
65
+ let results = Array.make(~length=items->Array.length, None)
66
+ let next = ref(0)
67
+ let worker = async () => {
68
+ let running = ref(true)
69
+ while running.contents {
70
+ let i = next.contents
71
+ if i >= items->Array.length {
72
+ running := false
73
+ } else {
74
+ next := i + 1
75
+ let r = await f(items->Array.getUnsafe(i))
76
+ results->Array.set(i, Some(r))
77
+ }
78
+ }
79
+ }
80
+ let _ = await Array.fromInitializer(~length=Math.Int.min(limit, items->Array.length), _ =>
81
+ worker()
82
+ )->Promise.all
83
+ results->Array.filterMap(x => x)
84
+ }
85
+
86
+ let errorText = (exn: exn): string =>
87
+ exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("unknown error")
88
+
89
+ // An update is rejected while another is still settling, and a stack that was
90
+ // deployed moments ago can still be settling. Poll rather than assume.
91
+ let awaitSettled = async (~client, ~functionName: string): unit => {
92
+ let deadline = 60
93
+ let rec poll = async (attempt: int): unit =>
94
+ if attempt < deadline {
95
+ let out = await Lambda.GetFunctionConfigurationCommand.send(
96
+ client,
97
+ Lambda.GetFunctionConfigurationCommand.make({functionName: functionName}),
98
+ )
99
+ switch out.lastUpdateStatus {
100
+ | Some("InProgress") =>
101
+ await ReventlessSeed.Seed.Client.sleep(1000)
102
+ await poll(attempt + 1)
103
+ | _ => ()
104
+ }
105
+ }
106
+ await poll(0)
107
+ }
108
+
109
+ let updateVariables = async (~client, ~functionName: string, ~variables: dict<string>): unit => {
110
+ await awaitSettled(~client, ~functionName)
111
+ let _ = await Lambda.UpdateFunctionConfigurationCommand.send(
112
+ client,
113
+ Lambda.UpdateFunctionConfigurationCommand.make({
114
+ functionName,
115
+ environment: {variables: variables},
116
+ }),
117
+ )
118
+ await awaitSettled(~client, ~functionName)
119
+ }
120
+
121
+ /** Put one function's reservation back exactly as it was — a value it had, or no
122
+ reservation at all. Never throws: a function left reserved at 0 is a function
123
+ left switched off, which has to be said rather than raised. */
124
+ let restoreConcurrency = async (~client, ~h: held): option<string> =>
125
+ switch await (
126
+ switch h.priorReserved {
127
+ | Some(n) =>
128
+ Lambda.PutFunctionConcurrencyCommand.send(
129
+ client,
130
+ Lambda.PutFunctionConcurrencyCommand.make({
131
+ functionName: h.functionName,
132
+ reservedConcurrentExecutions: n,
133
+ }),
134
+ )->Promise.thenResolve(_ => ())
135
+ | None =>
136
+ Lambda.DeleteFunctionConcurrencyCommand.send(
137
+ client,
138
+ Lambda.DeleteFunctionConcurrencyCommand.make({functionName: h.functionName}),
139
+ )->Promise.thenResolve(_ => ())
140
+ }
141
+ ) {
142
+ | () => None
143
+ | exception exn =>
144
+ Some(
145
+ `LEFT SWITCHED OFF: could not restore concurrency on ${h.functionName} (${errorText(exn)}). ` ++
146
+ `It is still reserved at 0 and will not run until that is undone.`,
147
+ )
148
+ }
149
+
150
+ /**
151
+ Hand the stack back: original environment first (which also drops the marker),
152
+ then the original concurrency.
153
+
154
+ That order matters. The environment restore is itself a configuration change, so
155
+ it recycles a second time; doing it while the function is still held means the
156
+ container that finally serves traffic is created after the restore, not during
157
+ it.
158
+
159
+ Never throws, for either step and for any function — this runs on the abort path
160
+ too, where an exception would replace the reason the reset failed with a
161
+ secondary one.
162
+ */
163
+ let release = async (~client, ~held: array<held>): array<string> => {
164
+ let warnings = await held->mapBounded(~limit=concurrency, async h => {
165
+ let envWarning = switch await updateVariables(
166
+ ~client,
167
+ ~functionName=h.functionName,
168
+ ~variables=h.priorVariables,
169
+ ) {
170
+ | () => None
171
+ | exception exn =>
172
+ Some(
173
+ `could not restore the environment of ${h.functionName} (${errorText(exn)}) — it may still ` ++
174
+ `carry ${markerKey}, which is inert and is removed by the next deploy.`,
175
+ )
176
+ }
177
+ let concurrencyWarning = await restoreConcurrency(~client, ~h)
178
+ [envWarning, concurrencyWarning]->Array.filterMap(w => w)
179
+ })
180
+ warnings->Array.flat
181
+ }
182
+
183
+ /**
184
+ Discard every held function's execution environments, so nothing that loaded
185
+ state before the wipe can write it back afterwards.
186
+
187
+ Never throws. A function that cannot be recycled is the one case where the reset
188
+ genuinely cannot promise the store stays empty, so it comes back as a warning
189
+ naming the function — the caller reports it rather than swallowing it.
190
+ */
191
+ let recycle = async (~client, ~held: array<held>): array<string> => {
192
+ let warnings = await held->mapBounded(~limit=concurrency, async h => {
193
+ let marked = h.priorVariables->Dict.copy
194
+ marked->Dict.set(markerKey, "1")
195
+ switch await updateVariables(~client, ~functionName=h.functionName, ~variables=marked) {
196
+ | () => None
197
+ | exception exn =>
198
+ Some(
199
+ `could not recycle ${h.functionName} (${errorText(exn)}) — a warm container may still hold ` ++
200
+ `pre-wipe state and write it back. Redeploy or update that function to clear it.`,
201
+ )
202
+ }
203
+ })
204
+ warnings->Array.filterMap(w => w)
205
+ }
206
+
207
+ /**
208
+ Take every named function out of service, recording what to put back.
209
+
210
+ Throws if any function cannot be held — before a single delete has been issued,
211
+ so a reset that cannot hold the platform still has the option of not starting.
212
+ The message names the IAM actions involved, because a missing permission is much
213
+ the likeliest cause and "AccessDenied" on its own does not say which one.
214
+
215
+ Crucially, it hands back whatever it did manage to take before throwing. The
216
+ functions are held concurrently, so a failure part-way through the batch leaves
217
+ earlier ones already at zero — and a reset that aborted while silently switching
218
+ off half a stack would be a worse failure than the one it was reporting. Only the
219
+ reservations are rolled back: this runs before `recycle`, so no environment has
220
+ been touched yet.
221
+ */
222
+ let hold = async (~client, ~functionNames: array<string>): array<held> => {
223
+ let attempts = await functionNames->mapBounded(~limit=concurrency, async functionName =>
224
+ switch await (
225
+ async () => {
226
+ let concurrencyOut = await Lambda.GetFunctionConcurrencyCommand.send(
227
+ client,
228
+ Lambda.GetFunctionConcurrencyCommand.make({functionName: functionName}),
229
+ )
230
+ let configOut = await Lambda.GetFunctionConfigurationCommand.send(
231
+ client,
232
+ Lambda.GetFunctionConfigurationCommand.make({functionName: functionName}),
233
+ )
234
+ let held = {
235
+ functionName,
236
+ priorReserved: concurrencyOut.reservedConcurrentExecutions,
237
+ priorVariables: configOut.environment
238
+ ->Option.flatMap(e => e.variables)
239
+ ->Option.getOr(Dict.make()),
240
+ }
241
+ let _ = await Lambda.PutFunctionConcurrencyCommand.send(
242
+ client,
243
+ Lambda.PutFunctionConcurrencyCommand.make({
244
+ functionName,
245
+ reservedConcurrentExecutions: 0,
246
+ }),
247
+ )
248
+ held
249
+ }
250
+ )() {
251
+ | held => Ok(held)
252
+ | exception exn => Error((functionName, errorText(exn)))
253
+ }
254
+ )
255
+
256
+ let taken = attempts->Array.filterMap(a =>
257
+ switch a {
258
+ | Ok(h) => Some(h)
259
+ | Error(_) => None
260
+ }
261
+ )
262
+ switch attempts->Array.findMap(a =>
263
+ switch a {
264
+ | Error(failure) => Some(failure)
265
+ | Ok(_) => None
266
+ }
267
+ ) {
268
+ | None => taken
269
+ | Some((functionName, reason)) =>
270
+ let rollback = await taken->mapBounded(~limit=concurrency, h => restoreConcurrency(~client, ~h))
271
+ let stranded = rollback->Array.filterMap(w => w)
272
+ throw(
273
+ ReventlessSeed.Seed.Failed(
274
+ `could not hold Lambda function ${functionName} at zero concurrency (${reason}) — nothing was ` ++
275
+ `deleted. The reset holds every runtime in scope for the length of the wipe, which needs ` ++
276
+ `lambda:GetFunctionConcurrency, lambda:GetFunctionConfiguration, lambda:PutFunctionConcurrency, ` ++
277
+ `lambda:DeleteFunctionConcurrency and lambda:UpdateFunctionConfiguration. Set ` ++
278
+ `SEED_RESET_NO_QUIESCE=1 to wipe without the hold — but a running runtime can then write back ` ++
279
+ `what the wipe removes.` ++
280
+ switch stranded {
281
+ | [] => ""
282
+ | messages => `\n\n ` ++ messages->Array.join("\n ")
283
+ },
284
+ ),
285
+ )
286
+ }
287
+ }
@@ -0,0 +1,205 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
4
+ import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
5
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
+ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
7
+ import * as Seed$ReventlessSeed from "@reventlessdev/reventless-seed/src/Seed.res.mjs";
8
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
9
+ import * as ClientLambda from "@aws-sdk/client-lambda";
10
+ import * as Seed_Client$ReventlessSeed from "@reventlessdev/reventless-seed/src/Seed_Client.res.mjs";
11
+
12
+ let markerKey = "REVENTLESS_RESET_RECYCLE";
13
+
14
+ async function mapBounded(items, limit, f) {
15
+ let results = Stdlib_Array.make(items.length, undefined);
16
+ let next = {
17
+ contents: 0
18
+ };
19
+ let worker = async () => {
20
+ let running = true;
21
+ while (running) {
22
+ let i = next.contents;
23
+ if (i >= items.length) {
24
+ running = false;
25
+ } else {
26
+ next.contents = i + 1 | 0;
27
+ let r = await f(items[i]);
28
+ results[i] = Primitive_option.some(r);
29
+ }
30
+ };
31
+ };
32
+ await Promise.all(Stdlib_Array.fromInitializer(Math.min(limit, items.length), param => worker()));
33
+ return Stdlib_Array.filterMap(results, x => x);
34
+ }
35
+
36
+ function errorText(exn) {
37
+ return Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), "unknown error");
38
+ }
39
+
40
+ async function awaitSettled(client, functionName) {
41
+ let poll = async attempt => {
42
+ if (attempt >= 60) {
43
+ return;
44
+ }
45
+ let out = await client.send(new ClientLambda.GetFunctionConfigurationCommand({
46
+ FunctionName: functionName
47
+ }));
48
+ let match = out.LastUpdateStatus;
49
+ if (match === undefined) {
50
+ return;
51
+ }
52
+ if (match !== "InProgress") {
53
+ return;
54
+ }
55
+ await Seed_Client$ReventlessSeed.sleep(1000);
56
+ return await poll(attempt + 1 | 0);
57
+ };
58
+ return await poll(0);
59
+ }
60
+
61
+ async function updateVariables(client, functionName, variables) {
62
+ await awaitSettled(client, functionName);
63
+ await client.send(new ClientLambda.UpdateFunctionConfigurationCommand({
64
+ FunctionName: functionName,
65
+ Environment: {
66
+ Variables: variables
67
+ }
68
+ }));
69
+ return await awaitSettled(client, functionName);
70
+ }
71
+
72
+ async function restoreConcurrency(client, h) {
73
+ try {
74
+ let n = h.priorReserved;
75
+ await (
76
+ n !== undefined ? client.send(new ClientLambda.PutFunctionConcurrencyCommand({
77
+ FunctionName: h.functionName,
78
+ ReservedConcurrentExecutions: n
79
+ })).then(param => {}) : client.send(new ClientLambda.DeleteFunctionConcurrencyCommand({
80
+ FunctionName: h.functionName
81
+ })).then(param => {})
82
+ );
83
+ return;
84
+ } catch (raw_exn) {
85
+ let exn = Primitive_exceptions.internalToException(raw_exn);
86
+ return `LEFT SWITCHED OFF: could not restore concurrency on ` + h.functionName + ` (` + errorText(exn) + `). It is still reserved at 0 and will not run until that is undone.`;
87
+ }
88
+ }
89
+
90
+ async function release(client, held) {
91
+ return (await mapBounded(held, 6, async h => {
92
+ let envWarning;
93
+ try {
94
+ await updateVariables(client, h.functionName, h.priorVariables);
95
+ envWarning = undefined;
96
+ } catch (raw_exn) {
97
+ let exn = Primitive_exceptions.internalToException(raw_exn);
98
+ envWarning = `could not restore the environment of ` + h.functionName + ` (` + errorText(exn) + `) — it may still ` + (`carry ` + markerKey + `, which is inert and is removed by the next deploy.`);
99
+ }
100
+ let concurrencyWarning = await restoreConcurrency(client, h);
101
+ return Stdlib_Array.filterMap([
102
+ envWarning,
103
+ concurrencyWarning
104
+ ], w => w);
105
+ })).flat();
106
+ }
107
+
108
+ async function recycle(client, held) {
109
+ let warnings = await mapBounded(held, 6, async h => {
110
+ let marked = Object.assign({}, h.priorVariables);
111
+ marked[markerKey] = "1";
112
+ try {
113
+ await updateVariables(client, h.functionName, marked);
114
+ return;
115
+ } catch (raw_exn) {
116
+ let exn = Primitive_exceptions.internalToException(raw_exn);
117
+ return `could not recycle ` + h.functionName + ` (` + errorText(exn) + `) — a warm container may still hold pre-wipe state and write it back. Redeploy or update that function to clear it.`;
118
+ }
119
+ });
120
+ return Stdlib_Array.filterMap(warnings, w => w);
121
+ }
122
+
123
+ async function hold(client, functionNames) {
124
+ let attempts = await mapBounded(functionNames, 6, async functionName => {
125
+ let held;
126
+ try {
127
+ held = await (async () => {
128
+ let concurrencyOut = await client.send(new ClientLambda.GetFunctionConcurrencyCommand({
129
+ FunctionName: functionName
130
+ }));
131
+ let configOut = await client.send(new ClientLambda.GetFunctionConfigurationCommand({
132
+ FunctionName: functionName
133
+ }));
134
+ let held_priorReserved = concurrencyOut.ReservedConcurrentExecutions;
135
+ let held_priorVariables = Stdlib_Option.getOr(Stdlib_Option.flatMap(configOut.Environment, e => e.Variables), {});
136
+ let held = {
137
+ functionName: functionName,
138
+ priorReserved: held_priorReserved,
139
+ priorVariables: held_priorVariables
140
+ };
141
+ await client.send(new ClientLambda.PutFunctionConcurrencyCommand({
142
+ FunctionName: functionName,
143
+ ReservedConcurrentExecutions: 0
144
+ }));
145
+ return held;
146
+ })();
147
+ } catch (raw_exn) {
148
+ let exn = Primitive_exceptions.internalToException(raw_exn);
149
+ return {
150
+ TAG: "Error",
151
+ _0: [
152
+ functionName,
153
+ errorText(exn)
154
+ ]
155
+ };
156
+ }
157
+ return {
158
+ TAG: "Ok",
159
+ _0: held
160
+ };
161
+ });
162
+ let taken = Stdlib_Array.filterMap(attempts, a => {
163
+ if (a.TAG === "Ok") {
164
+ return a._0;
165
+ }
166
+ });
167
+ let match = Stdlib_Array.findMap(attempts, a => {
168
+ if (a.TAG === "Ok") {
169
+ return;
170
+ } else {
171
+ return a._0;
172
+ }
173
+ });
174
+ if (match === undefined) {
175
+ return taken;
176
+ }
177
+ let rollback = await mapBounded(taken, 6, h => restoreConcurrency(client, h));
178
+ let stranded = Stdlib_Array.filterMap(rollback, w => w);
179
+ throw {
180
+ RE_EXN_ID: Seed$ReventlessSeed.Failed,
181
+ _1: `could not hold Lambda function ` + match[0] + ` at zero concurrency (` + match[1] + `) — nothing was deleted. The reset holds every runtime in scope for the length of the wipe, which needs lambda:GetFunctionConcurrency, lambda:GetFunctionConfiguration, lambda:PutFunctionConcurrency, lambda:DeleteFunctionConcurrency and lambda:UpdateFunctionConfiguration. Set SEED_RESET_NO_QUIESCE=1 to wipe without the hold — but a running runtime can then write back what the wipe removes.` + (
182
+ stranded.length !== 0 ? `\n\n ` + stranded.join("\n ") : ""
183
+ ),
184
+ Error: new Error()
185
+ };
186
+ }
187
+
188
+ let Lambda;
189
+
190
+ let concurrency = 6;
191
+
192
+ export {
193
+ Lambda,
194
+ markerKey,
195
+ concurrency,
196
+ mapBounded,
197
+ errorText,
198
+ awaitSettled,
199
+ updateVariables,
200
+ restoreConcurrency,
201
+ release,
202
+ recycle,
203
+ hold,
204
+ }
205
+ /* Stdlib_JsExn Not a pure module */
@@ -333,12 +333,8 @@ let run = (~stack=?, ~backend=?, ~targets: array<ReventlessSeedAws_Reset.target>
333
333
  await targets->Array.reduce(Promise.resolve(), (acc, target) =>
334
334
  acc->Promise.then(async _ => {
335
335
  let platform = ReventlessSeedAws_Reset.projectName(~projectDir=target.projectDir)
336
- let (found, _buckets) = await ReventlessSeedAws_Reset.discover(
337
- ~region,
338
- ~stack,
339
- ~platform,
340
- )
341
- found->Array.forEach(t => tables->Array.push(t))
336
+ let found = await ReventlessSeedAws_Reset.discover(~region, ~stack, ~platform)
337
+ found.tables->Array.forEach(t => tables->Array.push(t))
342
338
  })
343
339
  )
344
340
 
@@ -250,8 +250,8 @@ function run(stack, backend, targets, param) {
250
250
  let tables = [];
251
251
  await Stdlib_Array.reduce(targets, Promise.resolve(), (acc, target) => acc.then(async () => {
252
252
  let platform = ReventlessSeedAws_Reset.projectName(target.projectDir);
253
- let match = await ReventlessSeedAws_Reset.discover(region, stack$1, platform);
254
- match[0].forEach(t => {
253
+ let found = await ReventlessSeedAws_Reset.discover(region, stack$1, platform);
254
+ found.tables.forEach(t => {
255
255
  tables.push(t);
256
256
  });
257
257
  }));