@@ -196,12 +196,14 @@ void fxNewPromiseCapabilityCallback(txMachine* the)
196
196
197
197
void fxAddUnhandledRejection (txMachine * the , txSlot * promise )
198
198
{
199
+ txSlot * reason = mxPromiseResult (promise );
199
200
txSlot * list = & mxUnhandledPromises ;
200
201
txSlot * * address = & list -> value .reference -> next ;
201
202
txSlot * slot ;
202
203
while ((slot = * address )) {
203
204
if (slot -> value .weakRef .target == promise )
204
205
break ;
206
+ slot = slot -> next ;
205
207
address = & slot -> next ;
206
208
}
207
209
if (!slot ) {
@@ -211,26 +213,40 @@ void fxAddUnhandledRejection(txMachine* the, txSlot* promise)
211
213
slot = * address = fxNewSlot (the );
212
214
slot -> kind = XS_WEAK_REF_KIND ;
213
215
slot -> value .weakRef .target = promise ;
216
+ slot = slot -> next = fxNewSlot (the );
217
+ slot -> kind = reason -> kind ;
218
+ slot -> value = reason -> value ;
214
219
}
215
220
}
216
221
217
222
void fxCheckUnhandledRejections (txMachine * the , txBoolean atExit )
218
223
{
219
224
txSlot * list = & mxUnhandledPromises ;
220
225
if (atExit ) {
221
- if (list -> value .reference -> next )
226
+ txSlot * slot = list -> value .reference -> next ;
227
+ while (slot ) {
228
+ slot = slot -> next ;
229
+ mxException .value = slot -> value ;
230
+ mxException .kind = slot -> kind ;
222
231
fxAbort (the , XS_UNHANDLED_REJECTION_EXIT );
232
+ slot = slot -> next ;
233
+ }
223
234
}
224
235
else {
225
236
txSlot * * address = & list -> value .reference -> next ;
226
237
txSlot * slot ;
227
238
while ((slot = * address )) {
228
239
if (slot -> value .weakRef .target == C_NULL ) {
240
+ slot = slot -> next ;
229
241
* address = slot -> next ;
242
+ mxException .value = slot -> value ;
243
+ mxException .kind = slot -> kind ;
230
244
fxAbort (the , XS_UNHANDLED_REJECTION_EXIT );
231
245
}
232
- else
246
+ else {
247
+ slot = slot -> next ;
233
248
address = & slot -> next ;
249
+ }
234
250
}
235
251
}
236
252
}
@@ -1105,9 +1121,11 @@ void fxQueueJob(txMachine* the, txInteger count, txSlot* promise)
1105
1121
txSlot * * address = & list -> value .reference -> next ;
1106
1122
while ((slot = * address )) {
1107
1123
if (slot -> value .weakRef .target == promise ) {
1124
+ slot = slot -> next ;
1108
1125
* address = slot -> next ;
1109
1126
break ;
1110
1127
}
1128
+ slot = slot -> next ;
1111
1129
address = & slot -> next ;
1112
1130
}
1113
1131
#ifdef mxPromisePrint
0 commit comments