@@ -238,10 +238,8 @@ impl PromiseConstructor {
238
238
) ) ;
239
239
}
240
240
241
- // Get the first argument from the ArgumentsList
242
241
let first_arg = arguments. get ( 0 ) . bind ( gc. nogc ( ) ) ;
243
242
244
- // Try to convert to Array to extract promises
245
243
let Ok ( promise_array) = Array :: try_from ( first_arg. unbind ( ) ) else {
246
244
return Err ( agent. throw_exception_with_static_message (
247
245
ExceptionType :: TypeError ,
@@ -250,7 +248,6 @@ impl PromiseConstructor {
250
248
) ) ;
251
249
} ;
252
250
253
- // Get the first promise from the array
254
251
let array_slice = promise_array. as_slice ( agent) ;
255
252
if array_slice. is_empty ( ) {
256
253
return Err ( agent. throw_exception_with_static_message (
@@ -268,7 +265,6 @@ impl PromiseConstructor {
268
265
) ) ;
269
266
} ;
270
267
271
- // Convert Value to Promise
272
268
let Value :: Promise ( promise_to_await) = first_element. unbind ( ) else {
273
269
return Err ( agent. throw_exception_with_static_message (
274
270
ExceptionType :: TypeError ,
@@ -277,62 +273,12 @@ impl PromiseConstructor {
277
273
) ) ;
278
274
} ;
279
275
280
- // Check if the promise is already settled
281
- if let Some ( result) = promise_to_await. try_get_result ( agent, gc. nogc ( ) ) {
282
- // Promise is already settled, return its result
283
- match result {
284
- Ok ( value) => {
285
- // Create a resolved promise with the value
286
- let result_capability = PromiseCapability :: new ( agent, gc. nogc ( ) ) ;
287
- let result_promise = result_capability. promise ( ) . scope ( agent, gc. nogc ( ) ) ;
288
- result_capability
289
- . unbind ( )
290
- . resolve ( agent, value. unbind ( ) , gc. reborrow ( ) ) ;
291
- return Ok ( result_promise. get ( agent) . into_value ( ) ) ;
292
- }
293
- Err ( error) => {
294
- // Create a rejected promise with the error
295
- return Ok ( Promise :: new_rejected (
296
- agent,
297
- error. value ( ) . unbind ( ) ,
298
- gc. into_nogc ( ) ,
299
- )
300
- . into_value ( ) ) ;
301
- }
302
- }
303
- }
304
-
305
- // Promise is pending, we need to wait for it using await reaction
306
- // Create a promise capability for our result
307
276
let result_capability = PromiseCapability :: new ( agent, gc. nogc ( ) ) ;
308
277
let result_promise = result_capability. promise ( ) . scope ( agent, gc. nogc ( ) ) ;
309
278
310
- // For await reactions, we typically need an async executable and execution context
311
- // Since we're in Promise.all (not an async function), we'll use a simpler approach
312
- // and use regular promise reactions instead of await reactions
313
-
314
- // Use inner_promise_then to wait for the promise
315
- // For simplicity, we'll use Empty handlers which will pass through the value
316
279
let fulfill_handler = PromiseReactionHandler :: Empty ;
317
280
let reject_handler = PromiseReactionHandler :: Empty ;
318
281
319
- // Note: For a real await reaction, you would need:
320
- // 1. An AwaitReactionRecord with execution context and VM state
321
- // 2. A suspended VM that can be resumed
322
- // 3. An async executable (async function or module)
323
-
324
- // Here's how you would create an await reaction (commented out as it requires more setup):
325
- /*
326
- let await_reaction_record = AwaitReactionRecord {
327
- vm: Some(suspended_vm), // Would need a suspended VM
328
- async_executable: Some(AsyncExecutable::AsyncFunction(async_function)), // Would need async function
329
- execution_context: Some(execution_context), // Would need execution context
330
- return_promise_capability: result_capability.clone(),
331
- };
332
- let await_reaction = agent.heap.create(await_reaction_record);
333
- let await_handler = PromiseReactionHandler::Await(await_reaction);
334
- */
335
-
336
282
// For now, let's use a simpler approach that demonstrates the concept
337
283
inner_promise_then (
338
284
agent,
0 commit comments