@quenty/promise 10.18.0 → 10.19.0
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 +52 -342
- package/deploy.nevermore.json +10 -0
- package/package.json +5 -3
- package/src/Shared/Promise.lua +3 -3
- package/src/Shared/PromiseRetryUtils.lua +10 -0
- package/src/Shared/PromiseRetryUtils.spec.lua +109 -0
- package/src/Shared/PromiseTestUtils.lua +86 -0
- package/src/Shared/PromiseTestUtils.spec.lua +75 -0
- package/src/Shared/PromiseUtils.lua +16 -3
- package/src/Shared/Utility/promiseChild.lua +1 -1
- package/src/jest.config.lua +3 -0
- package/test/default.project.json +25 -0
- package/test/scripts/Server/ServerMain.server.lua +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,311 +3,178 @@
|
|
|
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
|
-
# [10.
|
|
6
|
+
# [10.19.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.18.1...@quenty/promise@10.19.0) (2026-07-18)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @quenty/promise
|
|
9
9
|
|
|
10
|
+
## [10.18.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.18.0...@quenty/promise@10.18.1) (2026-05-30)
|
|
10
11
|
|
|
12
|
+
**Note:** Version bump only for package @quenty/promise
|
|
11
13
|
|
|
14
|
+
# [10.18.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.17.0...@quenty/promise@10.18.0) (2026-04-23)
|
|
12
15
|
|
|
16
|
+
**Note:** Version bump only for package @quenty/promise
|
|
13
17
|
|
|
14
18
|
# [10.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.16.0...@quenty/promise@10.17.0) (2026-04-14)
|
|
15
19
|
|
|
16
|
-
|
|
17
20
|
### Bug Fixes
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
- Better promiseChild timeout message ([75ee035](https://github.com/Quenty/NevermoreEngine/commit/75ee035ed5465c5f8f6cc5d505d06e7084e4cc6e))
|
|
24
23
|
|
|
25
24
|
# [10.16.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.15.0...@quenty/promise@10.16.0) (2026-02-20)
|
|
26
25
|
|
|
27
26
|
**Note:** Version bump only for package @quenty/promise
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
28
|
# [10.15.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.14.0...@quenty/promise@10.15.0) (2026-02-19)
|
|
34
29
|
|
|
35
30
|
**Note:** Version bump only for package @quenty/promise
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
32
|
# [10.14.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.13.0...@quenty/promise@10.14.0) (2026-02-17)
|
|
42
33
|
|
|
43
34
|
**Note:** Version bump only for package @quenty/promise
|
|
44
35
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
36
|
# [10.13.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.12.6...@quenty/promise@10.13.0) (2026-01-13)
|
|
50
37
|
|
|
51
|
-
|
|
52
38
|
### Features
|
|
53
39
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
- Add new datastore session locking ([52f1a4b](https://github.com/Quenty/NevermoreEngine/commit/52f1a4b8988e9271ca639b0fec43315bb63ae97b))
|
|
59
41
|
|
|
60
42
|
## [10.12.6](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.12.5...@quenty/promise@10.12.6) (2026-01-12)
|
|
61
43
|
|
|
62
|
-
|
|
63
44
|
### Bug Fixes
|
|
64
45
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
46
|
+
- Fix dependency installation process for pnpm ([9651b09](https://github.com/Quenty/NevermoreEngine/commit/9651b09af34f252ef3f9c7c539793cc878dd8cba))
|
|
70
47
|
|
|
71
48
|
## [10.12.5](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.12.4...@quenty/promise@10.12.5) (2026-01-10)
|
|
72
49
|
|
|
73
50
|
**Note:** Version bump only for package @quenty/promise
|
|
74
51
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
52
|
## [10.12.4](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.12.3...@quenty/promise@10.12.4) (2026-01-03)
|
|
80
53
|
|
|
81
54
|
**Note:** Version bump only for package @quenty/promise
|
|
82
55
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
56
|
## [10.12.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.12.2...@quenty/promise@10.12.3) (2025-12-31)
|
|
88
57
|
|
|
89
|
-
|
|
90
58
|
### Bug Fixes
|
|
91
59
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
60
|
+
- Fix dependencies missing in packages ([97bd47d](https://github.com/Quenty/NevermoreEngine/commit/97bd47d341017152f91a28d8444252d20a8de9fa))
|
|
97
61
|
|
|
98
62
|
## [10.12.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.12.1...@quenty/promise@10.12.2) (2025-12-29)
|
|
99
63
|
|
|
100
|
-
|
|
101
64
|
### Bug Fixes
|
|
102
65
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
66
|
+
- Add fallback message for promise rejection ([34546af](https://github.com/Quenty/NevermoreEngine/commit/34546af3dde159c855f8933fa227df5d7cd6f333))
|
|
108
67
|
|
|
109
68
|
## [10.12.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.12.0...@quenty/promise@10.12.1) (2025-12-29)
|
|
110
69
|
|
|
111
|
-
|
|
112
70
|
### Bug Fixes
|
|
113
71
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
72
|
+
- Update typing to be more accurate ([e4c3d05](https://github.com/Quenty/NevermoreEngine/commit/e4c3d05a0aa9f45a37cbfa372c5e0d8a748c9323))
|
|
119
73
|
|
|
120
74
|
# [10.12.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.11.0...@quenty/promise@10.12.0) (2025-08-29)
|
|
121
75
|
|
|
122
|
-
|
|
123
76
|
### Features
|
|
124
77
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
78
|
+
- Add datastore session locking system ([#580](https://github.com/Quenty/NevermoreEngine/issues/580)) ([06ecef6](https://github.com/Quenty/NevermoreEngine/commit/06ecef60eab81ac0b44d9e408313fb4cc4d59488))
|
|
130
79
|
|
|
131
80
|
# [10.11.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.10.4...@quenty/promise@10.11.0) (2025-05-10)
|
|
132
81
|
|
|
133
|
-
|
|
134
82
|
### Bug Fixes
|
|
135
83
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
84
|
+
- Additional type checking updates ([05ba29a](https://github.com/Quenty/NevermoreEngine/commit/05ba29a03efc9f3feed74b34f1d9dfb237496214))
|
|
141
85
|
|
|
142
86
|
## [10.10.4](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.10.3...@quenty/promise@10.10.4) (2025-04-10)
|
|
143
87
|
|
|
144
88
|
**Note:** Version bump only for package @quenty/promise
|
|
145
89
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
90
|
## [10.10.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.10.1...@quenty/promise@10.10.3) (2025-04-07)
|
|
151
91
|
|
|
152
|
-
|
|
153
92
|
### Bug Fixes
|
|
154
93
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
94
|
+
- Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
95
|
+
- Bump package versions for republishing ([ba47c62](https://github.com/Quenty/NevermoreEngine/commit/ba47c62e32170bf74377b0c658c60b84306dc294))
|
|
161
96
|
|
|
162
97
|
## [10.10.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.10.1...@quenty/promise@10.10.2) (2025-04-07)
|
|
163
98
|
|
|
164
|
-
|
|
165
99
|
### Bug Fixes
|
|
166
100
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
101
|
+
- Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
172
102
|
|
|
173
103
|
## [10.10.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.10.0...@quenty/promise@10.10.1) (2025-03-21)
|
|
174
104
|
|
|
175
105
|
**Note:** Version bump only for package @quenty/promise
|
|
176
106
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
107
|
# [10.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.9.0...@quenty/promise@10.10.0) (2025-02-18)
|
|
182
108
|
|
|
183
109
|
**Note:** Version bump only for package @quenty/promise
|
|
184
110
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
111
|
# [10.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.8.0...@quenty/promise@10.9.0) (2024-12-15)
|
|
190
112
|
|
|
191
|
-
|
|
192
113
|
### Features
|
|
193
114
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
115
|
+
- Add retry mechanism to UserInfoAggregator ([7ff28b9](https://github.com/Quenty/NevermoreEngine/commit/7ff28b98173b376389496d6d895ba564edf4b337))
|
|
199
116
|
|
|
200
117
|
# [10.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.7.1...@quenty/promise@10.8.0) (2024-11-06)
|
|
201
118
|
|
|
202
|
-
|
|
203
119
|
### Bug Fixes
|
|
204
120
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
121
|
+
- Better stack traces ([247ce9b](https://github.com/Quenty/NevermoreEngine/commit/247ce9bd97753dec8c8fd6674f93cba2c7deca05))
|
|
210
122
|
|
|
211
123
|
## [10.7.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.7.0...@quenty/promise@10.7.1) (2024-11-04)
|
|
212
124
|
|
|
213
125
|
**Note:** Version bump only for package @quenty/promise
|
|
214
126
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
127
|
# [10.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.6.0...@quenty/promise@10.7.0) (2024-10-06)
|
|
220
128
|
|
|
221
129
|
**Note:** Version bump only for package @quenty/promise
|
|
222
130
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
131
|
# [10.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.5.0...@quenty/promise@10.6.0) (2024-10-04)
|
|
228
132
|
|
|
229
|
-
|
|
230
133
|
### Performance Improvements
|
|
231
134
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
135
|
+
- Use coroutine.running() for promise yielding ([658de34](https://github.com/Quenty/NevermoreEngine/commit/658de34e1bff418a5076065c07f7ddb4300db514))
|
|
237
136
|
|
|
238
137
|
# [10.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.4.0...@quenty/promise@10.5.0) (2024-09-25)
|
|
239
138
|
|
|
240
139
|
**Note:** Version bump only for package @quenty/promise
|
|
241
140
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
141
|
# [10.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.3.0...@quenty/promise@10.4.0) (2024-09-12)
|
|
247
142
|
|
|
248
|
-
|
|
249
143
|
### Features
|
|
250
144
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
145
|
+
- Add PromiseUtils.firstSuccessOrLastFailure(promises) ([1dc9bd7](https://github.com/Quenty/NevermoreEngine/commit/1dc9bd7a6851a29339fa8f61bd887d64fc4fed92))
|
|
256
146
|
|
|
257
147
|
# [10.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.2.0...@quenty/promise@10.3.0) (2024-05-09)
|
|
258
148
|
|
|
259
|
-
|
|
260
149
|
### Bug Fixes
|
|
261
150
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
151
|
+
- Fix .package-lock.json replicating in packages ([75d0efe](https://github.com/Quenty/NevermoreEngine/commit/75d0efeef239f221d93352af71a5b3e930ec23c5))
|
|
267
152
|
|
|
268
153
|
# [10.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.1.0...@quenty/promise@10.2.0) (2024-04-27)
|
|
269
154
|
|
|
270
155
|
**Note:** Version bump only for package @quenty/promise
|
|
271
156
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
157
|
# [10.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.0.0...@quenty/promise@10.1.0) (2024-03-09)
|
|
277
158
|
|
|
278
159
|
**Note:** Version bump only for package @quenty/promise
|
|
279
160
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
161
|
# [10.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@9.0.0...@quenty/promise@10.0.0) (2024-02-14)
|
|
285
162
|
|
|
286
163
|
**Note:** Version bump only for package @quenty/promise
|
|
287
164
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
165
|
# [9.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@8.0.0...@quenty/promise@9.0.0) (2024-02-13)
|
|
293
166
|
|
|
294
167
|
**Note:** Version bump only for package @quenty/promise
|
|
295
168
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
169
|
# [8.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@7.2.0...@quenty/promise@8.0.0) (2024-02-13)
|
|
301
170
|
|
|
302
|
-
|
|
303
171
|
### Features
|
|
304
172
|
|
|
305
|
-
|
|
306
|
-
|
|
173
|
+
- New loader (breaking changes), fixing loader issues ([#439](https://github.com/Quenty/NevermoreEngine/issues/439)) ([3534345](https://github.com/Quenty/NevermoreEngine/commit/353434522918812953bd9f13fece73e27a4d034d))
|
|
307
174
|
|
|
308
175
|
### BREAKING CHANGES
|
|
309
176
|
|
|
310
|
-
|
|
177
|
+
- Standard loader
|
|
311
178
|
|
|
312
179
|
Adds new loader version which replicates full structure instead of some partial structure. This allows us to have hot-reloading (in the future), as well as generally do less computation, handle dependencies more carefully, and other changes.
|
|
313
180
|
|
|
@@ -315,360 +182,203 @@ This means you'll need to change you how require client-side modules, as we expo
|
|
|
315
182
|
|
|
316
183
|
Signed-off-by: James Onnen <jonnen0@gmail.com>
|
|
317
184
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
* feat: Add RxPhysicsUtils.observePartMass
|
|
321
|
-
|
|
322
|
-
* fix: Fix package discovery for games
|
|
323
|
-
|
|
324
|
-
* feat: Add UIAlignmentUtils.verticalToHorizontalAlignment(verticalAlignment) and UIAlignmentUtils.horizontalToVerticalAlignment(horizontalAlignment)
|
|
325
|
-
|
|
326
|
-
* feat: AdorneeData:InitAttributes() does not require data as a secondparameter
|
|
185
|
+
- fix: Fix missing dependency in ResetService
|
|
327
186
|
|
|
328
|
-
|
|
187
|
+
- feat: Add RxPhysicsUtils.observePartMass
|
|
329
188
|
|
|
330
|
-
|
|
189
|
+
- fix: Fix package discovery for games
|
|
331
190
|
|
|
332
|
-
|
|
191
|
+
- feat: Add UIAlignmentUtils.verticalToHorizontalAlignment(verticalAlignment) and UIAlignmentUtils.horizontalToVerticalAlignment(horizontalAlignment)
|
|
333
192
|
|
|
334
|
-
|
|
193
|
+
- feat: AdorneeData:InitAttributes() does not require data as a secondparameter
|
|
335
194
|
|
|
336
|
-
|
|
195
|
+
- ci: Upgrade to new rojo 7.4.0
|
|
337
196
|
|
|
338
|
-
|
|
197
|
+
- fix: Update loader to handle hoarcekat properly
|
|
339
198
|
|
|
340
|
-
|
|
199
|
+
- docs: Fix spacing in Maid
|
|
341
200
|
|
|
342
|
-
|
|
201
|
+
- fix: Add new ragdoll constants
|
|
343
202
|
|
|
344
|
-
|
|
203
|
+
- fix: Compress influxDB sends
|
|
345
204
|
|
|
346
|
-
|
|
205
|
+
- style: Errors use string.format
|
|
347
206
|
|
|
207
|
+
- fix: Handle motor animations
|
|
348
208
|
|
|
209
|
+
- ci: Upgrade rojo version
|
|
349
210
|
|
|
211
|
+
- feat!: Maid no longer is includd in ValueObject.Changed event
|
|
350
212
|
|
|
213
|
+
- docs: Fix docs
|
|
351
214
|
|
|
352
215
|
# [7.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@7.1.0...@quenty/promise@7.2.0) (2024-01-08)
|
|
353
216
|
|
|
354
217
|
**Note:** Version bump only for package @quenty/promise
|
|
355
218
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
219
|
# [7.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@7.0.0...@quenty/promise@7.1.0) (2023-12-14)
|
|
361
220
|
|
|
362
221
|
**Note:** Version bump only for package @quenty/promise
|
|
363
222
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
223
|
# [7.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.8.0...@quenty/promise@7.0.0) (2023-10-11)
|
|
369
224
|
|
|
370
225
|
**Note:** Version bump only for package @quenty/promise
|
|
371
226
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
227
|
# [6.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.7.0...@quenty/promise@6.8.0) (2023-08-23)
|
|
377
228
|
|
|
378
|
-
|
|
379
229
|
### Features
|
|
380
230
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
231
|
+
- Add Promise.delay(seconds, func) ([db100f3](https://github.com/Quenty/NevermoreEngine/commit/db100f3212928f52ba47be089e6bc2f3d3e05f75))
|
|
386
232
|
|
|
387
233
|
# [6.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.6.0...@quenty/promise@6.7.0) (2023-07-28)
|
|
388
234
|
|
|
389
235
|
**Note:** Version bump only for package @quenty/promise
|
|
390
236
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
237
|
# [6.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.5.0...@quenty/promise@6.6.0) (2023-06-17)
|
|
396
238
|
|
|
397
|
-
|
|
398
239
|
### Features
|
|
399
240
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
241
|
+
- Performance gain from PromiseUtils.combine() ([b7cdd9f](https://github.com/Quenty/NevermoreEngine/commit/b7cdd9f67bf5d6933b0335524bad353ba254ccf6))
|
|
405
242
|
|
|
406
243
|
# [6.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.4.1...@quenty/promise@6.5.0) (2023-04-10)
|
|
407
244
|
|
|
408
|
-
|
|
409
245
|
### Features
|
|
410
246
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
247
|
+
- Add better error messaging to promise ([25221f4](https://github.com/Quenty/NevermoreEngine/commit/25221f450cab71bc8a38300c21099feaad23f168))
|
|
416
248
|
|
|
417
249
|
## [6.4.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.4.0...@quenty/promise@6.4.1) (2023-04-07)
|
|
418
250
|
|
|
419
251
|
**Note:** Version bump only for package @quenty/promise
|
|
420
252
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
253
|
# [6.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.3.0...@quenty/promise@6.4.0) (2023-03-31)
|
|
426
254
|
|
|
427
|
-
|
|
428
255
|
### Features
|
|
429
256
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
257
|
+
- Add PromiseUtils.combine(stateTable) ([1cb3606](https://github.com/Quenty/NevermoreEngine/commit/1cb36067fa80e7a86746dbee9f1fa07f9f9766bf))
|
|
435
258
|
|
|
436
259
|
# [6.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.2.0...@quenty/promise@6.3.0) (2023-03-05)
|
|
437
260
|
|
|
438
261
|
**Note:** Version bump only for package @quenty/promise
|
|
439
262
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
263
|
# [6.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.1.0...@quenty/promise@6.2.0) (2023-02-27)
|
|
445
264
|
|
|
446
265
|
**Note:** Version bump only for package @quenty/promise
|
|
447
266
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
267
|
# [6.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.0.1...@quenty/promise@6.1.0) (2023-02-21)
|
|
453
268
|
|
|
454
269
|
**Note:** Version bump only for package @quenty/promise
|
|
455
270
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
271
|
## [6.0.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@6.0.0...@quenty/promise@6.0.1) (2022-11-04)
|
|
461
272
|
|
|
462
273
|
**Note:** Version bump only for package @quenty/promise
|
|
463
274
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
275
|
# [6.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@5.1.1...@quenty/promise@6.0.0) (2022-09-27)
|
|
469
276
|
|
|
470
|
-
|
|
471
277
|
### Bug Fixes
|
|
472
278
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
279
|
+
- Fix function returning call scenario ([7a099f3](https://github.com/Quenty/NevermoreEngine/commit/7a099f320918a6a520ed9e35c5e777cf895a05f6))
|
|
478
280
|
|
|
479
281
|
## [5.1.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@5.1.0...@quenty/promise@5.1.1) (2022-08-16)
|
|
480
282
|
|
|
481
283
|
**Note:** Version bump only for package @quenty/promise
|
|
482
284
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
285
|
# [5.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@5.0.0...@quenty/promise@5.1.0) (2022-07-31)
|
|
488
286
|
|
|
489
|
-
|
|
490
287
|
### Bug Fixes
|
|
491
288
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
289
|
+
- Promise uses task.defer() instead of Heartbeat ([0ae1e7a](https://github.com/Quenty/NevermoreEngine/commit/0ae1e7aa92543bf220ebd594772dea9b6b586612))
|
|
290
|
+
- Replace coroutine.resume in favor of task.spawn ([#260](https://github.com/Quenty/NevermoreEngine/issues/260)) ([3686a1e](https://github.com/Quenty/NevermoreEngine/commit/3686a1e7926c0c5d116bd51843a95a5bb4e33743))
|
|
498
291
|
|
|
499
292
|
# [5.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@4.2.0...@quenty/promise@5.0.0) (2022-05-21)
|
|
500
293
|
|
|
501
294
|
**Note:** Version bump only for package @quenty/promise
|
|
502
295
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
296
|
# [4.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@4.1.0...@quenty/promise@4.2.0) (2022-03-27)
|
|
508
297
|
|
|
509
298
|
**Note:** Version bump only for package @quenty/promise
|
|
510
299
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
300
|
# [4.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@4.0.0...@quenty/promise@4.1.0) (2022-03-10)
|
|
516
301
|
|
|
517
302
|
**Note:** Version bump only for package @quenty/promise
|
|
518
303
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
304
|
# [4.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.6.0...@quenty/promise@4.0.0) (2022-03-06)
|
|
524
305
|
|
|
525
|
-
|
|
526
306
|
### Performance Improvements
|
|
527
307
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
308
|
+
- Return the promise transparently is we only have one promise ([f717878](https://github.com/Quenty/NevermoreEngine/commit/f7178782904ed8fc425365bb0c41f3ffd63ab013))
|
|
533
309
|
|
|
534
310
|
# [3.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.5.1...@quenty/promise@3.6.0) (2022-01-17)
|
|
535
311
|
|
|
536
312
|
**Note:** Version bump only for package @quenty/promise
|
|
537
313
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
314
|
## [3.5.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.5.0...@quenty/promise@3.5.1) (2022-01-16)
|
|
543
315
|
|
|
544
316
|
**Note:** Version bump only for package @quenty/promise
|
|
545
317
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
318
|
# [3.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.4.0...@quenty/promise@3.5.0) (2022-01-07)
|
|
551
319
|
|
|
552
320
|
**Note:** Version bump only for package @quenty/promise
|
|
553
321
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
322
|
# [3.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.3.1...@quenty/promise@3.4.0) (2022-01-03)
|
|
559
323
|
|
|
560
324
|
**Note:** Version bump only for package @quenty/promise
|
|
561
325
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
326
|
## [3.3.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.3.0...@quenty/promise@3.3.1) (2021-12-30)
|
|
567
327
|
|
|
568
328
|
**Note:** Version bump only for package @quenty/promise
|
|
569
329
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
330
|
# [3.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.2.0...@quenty/promise@3.3.0) (2021-12-18)
|
|
575
331
|
|
|
576
|
-
|
|
577
332
|
### Bug Fixes
|
|
578
333
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
334
|
+
- Use Promies.spawn() since task.spawn() is probably cheaper now ([6a069c2](https://github.com/Quenty/NevermoreEngine/commit/6a069c2a1c99ca34f53af747a969d5f5c4044e84))
|
|
584
335
|
|
|
585
336
|
# [3.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.1.2...@quenty/promise@3.2.0) (2021-11-20)
|
|
586
337
|
|
|
587
|
-
|
|
588
338
|
### Bug Fixes
|
|
589
339
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
340
|
+
- Support MacOS syncing ([#225](https://github.com/Quenty/NevermoreEngine/issues/225)) ([03f9183](https://github.com/Quenty/NevermoreEngine/commit/03f918392c6a5bdd33f8a17c38de371d1e06c67a))
|
|
595
341
|
|
|
596
342
|
## [3.1.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.1.1...@quenty/promise@3.1.2) (2021-10-30)
|
|
597
343
|
|
|
598
344
|
**Note:** Version bump only for package @quenty/promise
|
|
599
345
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
346
|
## [3.1.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.1.0...@quenty/promise@3.1.1) (2021-10-06)
|
|
605
347
|
|
|
606
348
|
**Note:** Version bump only for package @quenty/promise
|
|
607
349
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
350
|
# [3.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.0.1...@quenty/promise@3.1.0) (2021-10-02)
|
|
613
351
|
|
|
614
352
|
**Note:** Version bump only for package @quenty/promise
|
|
615
353
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
354
|
## [3.0.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@3.0.0...@quenty/promise@3.0.1) (2021-09-18)
|
|
621
355
|
|
|
622
356
|
**Note:** Version bump only for package @quenty/promise
|
|
623
357
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
358
|
# [3.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@2.1.0...@quenty/promise@3.0.0) (2021-09-11)
|
|
629
359
|
|
|
630
360
|
**Note:** Version bump only for package @quenty/promise
|
|
631
361
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
362
|
# [2.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@2.0.0...@quenty/promise@2.1.0) (2021-09-05)
|
|
637
363
|
|
|
638
364
|
**Note:** Version bump only for package @quenty/promise
|
|
639
365
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
366
|
# [2.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@1.2.0...@quenty/promise@2.0.0) (2021-09-05)
|
|
645
367
|
|
|
646
|
-
|
|
647
368
|
### Bug Fixes
|
|
648
369
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
370
|
+
- Remove peer dependencies. This is because lerna doesn't really support peer dependencies being linked and getting a new version on build, which is unfortunate. ([5f5aeee](https://github.com/Quenty/NevermoreEngine/commit/5f5aeeea8de9975435309e53679f0ef7064f9dd0))
|
|
654
371
|
|
|
655
372
|
# 1.2.0 (2021-07-31)
|
|
656
373
|
|
|
657
|
-
|
|
658
374
|
### Bug Fixes
|
|
659
375
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
376
|
+
- Add CI and CD ([47513e9](https://github.com/Quenty/NevermoreEngine/commit/47513e9b568162707534af132396dd8756947dd3))
|
|
377
|
+
- Adjust CI badge to show automatic build and release state ([5a55d3f](https://github.com/Quenty/NevermoreEngine/commit/5a55d3f19bf8d66a760d67da9b56ed47fab74656))
|
|
378
|
+
- Fix selene linting ([45fc074](https://github.com/Quenty/NevermoreEngine/commit/45fc07489ee59127ac6582689f19a0e87c1e5b5a))
|
|
665
379
|
|
|
666
380
|
## 1.0.2 (2021-07-25)
|
|
667
381
|
|
|
668
|
-
|
|
669
|
-
|
|
670
382
|
## 1.0.1 (2021-07-25)
|
|
671
383
|
|
|
672
|
-
|
|
673
|
-
|
|
674
384
|
# 1.0.0 (2021-07-24)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/promise",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.19.0",
|
|
4
4
|
"description": "Promise implementation for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -32,10 +32,12 @@
|
|
|
32
32
|
"@quenty/loader": "10.11.0",
|
|
33
33
|
"@quenty/maid": "3.9.0",
|
|
34
34
|
"@quenty/math": "2.7.5",
|
|
35
|
-
"@quenty/
|
|
35
|
+
"@quenty/nevermore-test-runner": "1.4.0",
|
|
36
|
+
"@quenty/signal": "7.13.1",
|
|
37
|
+
"@quentystudios/jest-lua": "3.10.0-quenty.2"
|
|
36
38
|
},
|
|
37
39
|
"publishConfig": {
|
|
38
40
|
"access": "public"
|
|
39
41
|
},
|
|
40
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "cbbb89635bfdcbf32f26a40422ac736292917cca"
|
|
41
43
|
}
|
package/src/Shared/Promise.lua
CHANGED
|
@@ -47,10 +47,10 @@ end
|
|
|
47
47
|
--[=[
|
|
48
48
|
Constructs a new promise.
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
:::warning
|
|
51
51
|
Do not yield within this func callback, as it will yield on the
|
|
52
52
|
main thread. This is a performance optimization.
|
|
53
|
-
|
|
53
|
+
:::
|
|
54
54
|
|
|
55
55
|
@param func (resolve: (...) -> (), reject: (...) -> ()) -> ()?
|
|
56
56
|
@return Promise<T...>
|
|
@@ -400,7 +400,7 @@ function Promise._toHumanReadable<T...>(_self: Promise<T...>, data: any): string
|
|
|
400
400
|
end
|
|
401
401
|
|
|
402
402
|
--[=[
|
|
403
|
-
|
|
403
|
+
Handles if/when promise is fulfilled/rejected. It takes up to two arguments, callback functions
|
|
404
404
|
for the success and failure cases of the Promise. May return the same promise if certain behavior
|
|
405
405
|
is met.
|
|
406
406
|
|
|
@@ -15,6 +15,9 @@ export type RetryOptions = {
|
|
|
15
15
|
initialWaitTime: number,
|
|
16
16
|
maxAttempts: number,
|
|
17
17
|
printWarning: boolean,
|
|
18
|
+
-- Optional predicate consulted after each failure. Returning false stops retrying immediately and
|
|
19
|
+
-- rejects with that error (for failures that will not resolve by retrying).
|
|
20
|
+
shouldRetry: ((any) -> boolean)?,
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
--[=[
|
|
@@ -54,6 +57,13 @@ function PromiseRetryUtils.retry<T...>(callback: () -> Promise.Promise<T...>, op
|
|
|
54
57
|
return
|
|
55
58
|
end
|
|
56
59
|
|
|
60
|
+
-- Bail out early on a failure that will not resolve by retrying.
|
|
61
|
+
if options.shouldRetry and not options.shouldRetry(lastResults[2]) then
|
|
62
|
+
isLoopResolved = true
|
|
63
|
+
promise:Reject(table.unpack(lastResults, 2, lastResults.n))
|
|
64
|
+
return
|
|
65
|
+
end
|
|
66
|
+
|
|
57
67
|
if attemptNumber ~= options.maxAttempts then
|
|
58
68
|
local thisWaitTime = Math.jitter(waitTime * ((options.exponential or 2) ^ (attemptNumber - 1)))
|
|
59
69
|
if options.printWarning then
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
--!nonstrict
|
|
2
|
+
--[[
|
|
3
|
+
@class PromiseRetryUtils.spec.lua
|
|
4
|
+
]]
|
|
5
|
+
|
|
6
|
+
local require = require(script.Parent.loader).load(script)
|
|
7
|
+
|
|
8
|
+
local Jest = require("Jest")
|
|
9
|
+
local Promise = require("Promise")
|
|
10
|
+
local PromiseRetryUtils = require("PromiseRetryUtils")
|
|
11
|
+
local PromiseTestUtils = require("PromiseTestUtils")
|
|
12
|
+
|
|
13
|
+
local describe = Jest.Globals.describe
|
|
14
|
+
local expect = Jest.Globals.expect
|
|
15
|
+
local it = Jest.Globals.it
|
|
16
|
+
|
|
17
|
+
local FAST_OPTIONS = {
|
|
18
|
+
initialWaitTime = 0,
|
|
19
|
+
maxAttempts = 3,
|
|
20
|
+
printWarning = false,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
-- Returns a callback that rejects with `errorMessage` for its first `failureCount` attempts, then
|
|
24
|
+
-- resolves with `value`, and a counter table exposing how many attempts were made.
|
|
25
|
+
local function newFlakyCallback(failureCount: number, errorMessage: string, value: any)
|
|
26
|
+
local attempts = { count = 0 }
|
|
27
|
+
local function callback()
|
|
28
|
+
attempts.count += 1
|
|
29
|
+
if attempts.count <= failureCount then
|
|
30
|
+
-- Reject asynchronously so retry attaches a rejection handler (consuming the exception)
|
|
31
|
+
-- rather than reading an already-rejected promise, which would be flagged as uncaught.
|
|
32
|
+
return Promise.defer(function(_resolve, reject)
|
|
33
|
+
reject(errorMessage)
|
|
34
|
+
end)
|
|
35
|
+
end
|
|
36
|
+
return Promise.resolved(value)
|
|
37
|
+
end
|
|
38
|
+
return callback, attempts
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe("PromiseRetryUtils.retry", function()
|
|
42
|
+
it("resolves on the first attempt without retrying", function()
|
|
43
|
+
local callback, attempts = newFlakyCallback(0, "boom", "done")
|
|
44
|
+
|
|
45
|
+
local outcome, value = PromiseTestUtils.awaitOutcome(PromiseRetryUtils.retry(callback, FAST_OPTIONS))
|
|
46
|
+
|
|
47
|
+
expect(outcome).toEqual("resolved")
|
|
48
|
+
expect(value).toEqual("done")
|
|
49
|
+
expect(attempts.count).toEqual(1)
|
|
50
|
+
end)
|
|
51
|
+
|
|
52
|
+
it("retries after a failure and resolves once the callback succeeds", function()
|
|
53
|
+
local callback, attempts = newFlakyCallback(2, "boom", "done")
|
|
54
|
+
|
|
55
|
+
local outcome, value = PromiseTestUtils.awaitOutcome(PromiseRetryUtils.retry(callback, FAST_OPTIONS))
|
|
56
|
+
|
|
57
|
+
expect(outcome).toEqual("resolved")
|
|
58
|
+
expect(value).toEqual("done")
|
|
59
|
+
expect(attempts.count).toEqual(3)
|
|
60
|
+
end)
|
|
61
|
+
|
|
62
|
+
it("rejects after exhausting maxAttempts", function()
|
|
63
|
+
local callback, attempts = newFlakyCallback(math.huge, "always fails", nil)
|
|
64
|
+
|
|
65
|
+
local outcome, err = PromiseTestUtils.awaitOutcome(PromiseRetryUtils.retry(callback, FAST_OPTIONS))
|
|
66
|
+
|
|
67
|
+
expect(outcome).toEqual("rejected")
|
|
68
|
+
expect(string.find(tostring(err), "always fails", 1, true) ~= nil).toEqual(true)
|
|
69
|
+
expect(attempts.count).toEqual(3)
|
|
70
|
+
end)
|
|
71
|
+
|
|
72
|
+
it("stops immediately and rejects with the error when shouldRetry returns false", function()
|
|
73
|
+
local callback, attempts = newFlakyCallback(math.huge, "fatal 509", nil)
|
|
74
|
+
|
|
75
|
+
local outcome, err = PromiseTestUtils.awaitOutcome(PromiseRetryUtils.retry(callback, {
|
|
76
|
+
initialWaitTime = 0,
|
|
77
|
+
maxAttempts = 5,
|
|
78
|
+
printWarning = false,
|
|
79
|
+
shouldRetry = function()
|
|
80
|
+
return false
|
|
81
|
+
end,
|
|
82
|
+
}))
|
|
83
|
+
|
|
84
|
+
expect(outcome).toEqual("rejected")
|
|
85
|
+
expect(err).toEqual("fatal 509")
|
|
86
|
+
expect(attempts.count).toEqual(1)
|
|
87
|
+
end)
|
|
88
|
+
|
|
89
|
+
it("keeps retrying while shouldRetry returns true", function()
|
|
90
|
+
local callback, attempts = newFlakyCallback(math.huge, "retryable", nil)
|
|
91
|
+
local consulted = { count = 0 }
|
|
92
|
+
|
|
93
|
+
local outcome = PromiseTestUtils.awaitOutcome(PromiseRetryUtils.retry(callback, {
|
|
94
|
+
initialWaitTime = 0,
|
|
95
|
+
maxAttempts = 3,
|
|
96
|
+
printWarning = false,
|
|
97
|
+
shouldRetry = function(err)
|
|
98
|
+
consulted.count += 1
|
|
99
|
+
expect(err).toEqual("retryable")
|
|
100
|
+
return true
|
|
101
|
+
end,
|
|
102
|
+
}))
|
|
103
|
+
|
|
104
|
+
expect(outcome).toEqual("rejected")
|
|
105
|
+
expect(attempts.count).toEqual(3)
|
|
106
|
+
-- Consulted after every failure, including the final attempt.
|
|
107
|
+
expect(consulted.count).toEqual(3)
|
|
108
|
+
end)
|
|
109
|
+
end)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--[=[
|
|
3
|
+
Test helpers for awaiting promises with a bounded timeout, so a hung promise fails the test
|
|
4
|
+
instead of freezing the runner. Awaiting races the promise against a timeout rather than polling
|
|
5
|
+
with `task.wait()`.
|
|
6
|
+
|
|
7
|
+
@class PromiseTestUtils
|
|
8
|
+
]=]
|
|
9
|
+
|
|
10
|
+
local require = require(script.Parent.loader).load(script)
|
|
11
|
+
|
|
12
|
+
local Promise = require("Promise")
|
|
13
|
+
local PromiseUtils = require("PromiseUtils")
|
|
14
|
+
|
|
15
|
+
local PromiseTestUtils = {}
|
|
16
|
+
|
|
17
|
+
local DEFAULT_TIMEOUT = 5
|
|
18
|
+
|
|
19
|
+
--[=[
|
|
20
|
+
Yields until the promise settles (resolves or rejects) or the timeout elapses. Races the promise
|
|
21
|
+
against a timeout instead of polling.
|
|
22
|
+
|
|
23
|
+
@param promise Promise
|
|
24
|
+
@param timeout number? -- Defaults to 5 seconds
|
|
25
|
+
@return boolean -- true if the promise settled, false if it timed out
|
|
26
|
+
]=]
|
|
27
|
+
function PromiseTestUtils.awaitSettled<T...>(promise: Promise.Promise<T...>, timeout: number?): boolean
|
|
28
|
+
if not promise:IsPending() then
|
|
29
|
+
-- Attach a handler so an already-rejected promise is not flagged as an uncaught exception.
|
|
30
|
+
promise:Catch(function() end)
|
|
31
|
+
return true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
local settled = Promise.new()
|
|
35
|
+
local function markSettled()
|
|
36
|
+
settled:Resolve(true)
|
|
37
|
+
end
|
|
38
|
+
promise:Then(markSettled, markSettled)
|
|
39
|
+
|
|
40
|
+
local timedOut = PromiseUtils.delayed(timeout or DEFAULT_TIMEOUT):Then(function()
|
|
41
|
+
return false
|
|
42
|
+
end)
|
|
43
|
+
|
|
44
|
+
return (PromiseUtils.race({ settled, timedOut }):Wait())
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
--[=[
|
|
48
|
+
Yields until the predicate returns a truthy value or the timeout elapses. Used when the awaited
|
|
49
|
+
condition is observable state rather than a promise.
|
|
50
|
+
|
|
51
|
+
@param predicate () -> boolean
|
|
52
|
+
@param timeout number? -- Defaults to 5 seconds
|
|
53
|
+
@return boolean -- The final predicate result
|
|
54
|
+
]=]
|
|
55
|
+
function PromiseTestUtils.awaitValue(predicate: () -> boolean, timeout: number?): boolean
|
|
56
|
+
local deadline = os.clock() + (timeout or DEFAULT_TIMEOUT)
|
|
57
|
+
while not predicate() and os.clock() < deadline do
|
|
58
|
+
task.wait()
|
|
59
|
+
end
|
|
60
|
+
return predicate()
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
--[=[
|
|
64
|
+
Attaches resolve/reject handlers synchronously (so the rejection is always handled and never
|
|
65
|
+
surfaces as an uncaught error) and yields for the outcome.
|
|
66
|
+
|
|
67
|
+
@param promise Promise
|
|
68
|
+
@param timeout number? -- Defaults to 5 seconds
|
|
69
|
+
@return "resolved" | "rejected" | "pending"
|
|
70
|
+
@return any -- The resolved value or rejection error
|
|
71
|
+
]=]
|
|
72
|
+
function PromiseTestUtils.awaitOutcome<T...>(promise: Promise.Promise<T...>, timeout: number?): (string, any)
|
|
73
|
+
local outcome: string?
|
|
74
|
+
local payload: any
|
|
75
|
+
promise:Then(function(value)
|
|
76
|
+
outcome, payload = "resolved", value
|
|
77
|
+
end, function(err)
|
|
78
|
+
outcome, payload = "rejected", err
|
|
79
|
+
end)
|
|
80
|
+
|
|
81
|
+
PromiseTestUtils.awaitSettled(promise, timeout)
|
|
82
|
+
|
|
83
|
+
return outcome or "pending", payload
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
return PromiseTestUtils
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
--!nonstrict
|
|
2
|
+
--[[
|
|
3
|
+
@class PromiseTestUtils.spec.lua
|
|
4
|
+
]]
|
|
5
|
+
|
|
6
|
+
local require = require(script.Parent.loader).load(script)
|
|
7
|
+
|
|
8
|
+
local Jest = require("Jest")
|
|
9
|
+
local Promise = require("Promise")
|
|
10
|
+
local PromiseTestUtils = require("PromiseTestUtils")
|
|
11
|
+
|
|
12
|
+
local describe = Jest.Globals.describe
|
|
13
|
+
local expect = Jest.Globals.expect
|
|
14
|
+
local it = Jest.Globals.it
|
|
15
|
+
|
|
16
|
+
local SHORT_TIMEOUT = 0.1
|
|
17
|
+
|
|
18
|
+
describe("PromiseTestUtils.awaitSettled", function()
|
|
19
|
+
it("returns true for an already-resolved promise", function()
|
|
20
|
+
expect(PromiseTestUtils.awaitSettled(Promise.resolved(1))).toEqual(true)
|
|
21
|
+
end)
|
|
22
|
+
|
|
23
|
+
it("returns true for a rejected promise", function()
|
|
24
|
+
expect(PromiseTestUtils.awaitSettled(Promise.rejected("boom"))).toEqual(true)
|
|
25
|
+
end)
|
|
26
|
+
|
|
27
|
+
it("returns true once a pending promise resolves", function()
|
|
28
|
+
local promise = Promise.new()
|
|
29
|
+
task.defer(function()
|
|
30
|
+
promise:Resolve(true)
|
|
31
|
+
end)
|
|
32
|
+
expect(PromiseTestUtils.awaitSettled(promise)).toEqual(true)
|
|
33
|
+
end)
|
|
34
|
+
|
|
35
|
+
it("returns false when the promise never settles within the timeout", function()
|
|
36
|
+
expect(PromiseTestUtils.awaitSettled(Promise.new(), SHORT_TIMEOUT)).toEqual(false)
|
|
37
|
+
end)
|
|
38
|
+
end)
|
|
39
|
+
|
|
40
|
+
describe("PromiseTestUtils.awaitOutcome", function()
|
|
41
|
+
it("reports a resolved value", function()
|
|
42
|
+
local outcome, value = PromiseTestUtils.awaitOutcome(Promise.resolved(42))
|
|
43
|
+
expect(outcome).toEqual("resolved")
|
|
44
|
+
expect(value).toEqual(42)
|
|
45
|
+
end)
|
|
46
|
+
|
|
47
|
+
it("reports a rejection error", function()
|
|
48
|
+
local outcome, err = PromiseTestUtils.awaitOutcome(Promise.rejected("boom"))
|
|
49
|
+
expect(outcome).toEqual("rejected")
|
|
50
|
+
expect(err).toEqual("boom")
|
|
51
|
+
end)
|
|
52
|
+
|
|
53
|
+
it("reports pending when the promise never settles within the timeout", function()
|
|
54
|
+
local outcome = PromiseTestUtils.awaitOutcome(Promise.new(), SHORT_TIMEOUT)
|
|
55
|
+
expect(outcome).toEqual("pending")
|
|
56
|
+
end)
|
|
57
|
+
end)
|
|
58
|
+
|
|
59
|
+
describe("PromiseTestUtils.awaitValue", function()
|
|
60
|
+
it("returns true once the predicate becomes true", function()
|
|
61
|
+
local flag = { value = false }
|
|
62
|
+
task.defer(function()
|
|
63
|
+
flag.value = true
|
|
64
|
+
end)
|
|
65
|
+
expect(PromiseTestUtils.awaitValue(function()
|
|
66
|
+
return flag.value
|
|
67
|
+
end)).toEqual(true)
|
|
68
|
+
end)
|
|
69
|
+
|
|
70
|
+
it("returns false when the predicate never becomes true within the timeout", function()
|
|
71
|
+
expect(PromiseTestUtils.awaitValue(function()
|
|
72
|
+
return false
|
|
73
|
+
end, SHORT_TIMEOUT)).toEqual(false)
|
|
74
|
+
end)
|
|
75
|
+
end)
|
|
@@ -12,9 +12,11 @@ local Signal = require("Signal")
|
|
|
12
12
|
local PromiseUtils = {}
|
|
13
13
|
|
|
14
14
|
--[=[
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
Settles with the first of the given promises to settle, resolving if it resolved or rejecting if
|
|
16
|
+
it rejected. Also available as [PromiseUtils.race].
|
|
17
|
+
|
|
18
|
+
@param promises { Promise<T...> }
|
|
19
|
+
@return Promise<T...> -- Promise that settles with the first result
|
|
18
20
|
]=]
|
|
19
21
|
function PromiseUtils.any<T...>(promises: { Promise.Promise<T...> }): Promise.Promise<T...>
|
|
20
22
|
local returnPromise = Promise.new()
|
|
@@ -34,6 +36,17 @@ function PromiseUtils.any<T...>(promises: { Promise.Promise<T...> }): Promise.Pr
|
|
|
34
36
|
return returnPromise
|
|
35
37
|
end
|
|
36
38
|
|
|
39
|
+
--[=[
|
|
40
|
+
Alias for [PromiseUtils.any]. Settles with the first of the given promises to settle, resolving
|
|
41
|
+
if it resolved or rejecting if it rejected.
|
|
42
|
+
|
|
43
|
+
@function race
|
|
44
|
+
@within PromiseUtils
|
|
45
|
+
@param promises { Promise<T...> }
|
|
46
|
+
@return Promise<T...>
|
|
47
|
+
]=]
|
|
48
|
+
PromiseUtils.race = PromiseUtils.any
|
|
49
|
+
|
|
37
50
|
--[=[
|
|
38
51
|
Returns a promise that will resolve after the set amount of seconds
|
|
39
52
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "PromiseTest",
|
|
3
|
+
"globIgnorePaths": [
|
|
4
|
+
"**/.package-lock.json",
|
|
5
|
+
"**/.pnpm",
|
|
6
|
+
"**/.pnpm-workspace-state-v1.json",
|
|
7
|
+
"**/.modules.yaml",
|
|
8
|
+
"**/.ignored",
|
|
9
|
+
"**/.ignored_*"
|
|
10
|
+
],
|
|
11
|
+
"tree": {
|
|
12
|
+
"$className": "DataModel",
|
|
13
|
+
"ServerScriptService": {
|
|
14
|
+
"$properties": {
|
|
15
|
+
"LoadStringEnabled": true
|
|
16
|
+
},
|
|
17
|
+
"promise": {
|
|
18
|
+
"$path": ".."
|
|
19
|
+
},
|
|
20
|
+
"Script": {
|
|
21
|
+
"$path": "scripts/Server"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
--!nonstrict
|
|
2
|
+
--[[
|
|
3
|
+
@class ServerMain
|
|
4
|
+
]]
|
|
5
|
+
|
|
6
|
+
local ServerScriptService = game:GetService("ServerScriptService")
|
|
7
|
+
|
|
8
|
+
local root = ServerScriptService.promise
|
|
9
|
+
local loader = root:FindFirstChild("LoaderUtils", true).Parent
|
|
10
|
+
local require = require(loader).bootstrapGame(root)
|
|
11
|
+
|
|
12
|
+
local NevermoreTestRunnerUtils = require("NevermoreTestRunnerUtils")
|
|
13
|
+
|
|
14
|
+
NevermoreTestRunnerUtils.runTestsIfNeededAsync(root)
|