Skip to content

Commit 05d71a0

Browse files
committed
Bug 1992103 - Align async modules rejection order with fulfillment order r=jonco
This patch inverts the order in which we reject promises in AsyncModuleExecutionRejected to match AsyncModuleExecutionFulfilled: first the promise corresponding to the leaf module (the one that throws) is rejected, and then its ancestors. This change was discussed at the July 2025 TC39 meeting. Spec PR: tc39/ecma262#3695 test262: tc39/test262#4591 Differential Revision: https://phabricator.services.mozilla.com/D267210 UltraBlame original commit: a3cf4d1eef17209c4c4194e07f38fe870c417781
1 parent 13e7d0e commit 05d71a0

File tree

1 file changed

+183
-46
lines changed

1 file changed

+183
-46
lines changed

js/src/vm/Modules.cpp

Lines changed: 183 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,143 @@ moduleObject
16281628
;
16291629
}
16301630
JS_PUBLIC_API
1631+
JSObject
1632+
*
1633+
JS
1634+
:
1635+
:
1636+
CreateCssModule
1637+
(
1638+
JSContext
1639+
*
1640+
cx
1641+
const
1642+
ReadOnlyCompileOptions
1643+
&
1644+
options
1645+
const
1646+
Value
1647+
&
1648+
cssValue
1649+
)
1650+
{
1651+
Rooted
1652+
<
1653+
ExportNameVector
1654+
>
1655+
exportNames
1656+
(
1657+
cx
1658+
)
1659+
;
1660+
if
1661+
(
1662+
!
1663+
exportNames
1664+
.
1665+
append
1666+
(
1667+
cx
1668+
-
1669+
>
1670+
names
1671+
(
1672+
)
1673+
.
1674+
default_
1675+
)
1676+
)
1677+
{
1678+
ReportOutOfMemory
1679+
(
1680+
cx
1681+
)
1682+
;
1683+
return
1684+
nullptr
1685+
;
1686+
}
1687+
Rooted
1688+
<
1689+
ModuleObject
1690+
*
1691+
>
1692+
moduleObject
1693+
(
1694+
cx
1695+
ModuleObject
1696+
:
1697+
:
1698+
createSynthetic
1699+
(
1700+
cx
1701+
&
1702+
exportNames
1703+
)
1704+
)
1705+
;
1706+
if
1707+
(
1708+
!
1709+
moduleObject
1710+
)
1711+
{
1712+
return
1713+
nullptr
1714+
;
1715+
}
1716+
RootedVector
1717+
<
1718+
Value
1719+
>
1720+
exportValues
1721+
(
1722+
cx
1723+
)
1724+
;
1725+
if
1726+
(
1727+
!
1728+
exportValues
1729+
.
1730+
append
1731+
(
1732+
cssValue
1733+
)
1734+
)
1735+
{
1736+
ReportOutOfMemory
1737+
(
1738+
cx
1739+
)
1740+
;
1741+
return
1742+
nullptr
1743+
;
1744+
}
1745+
if
1746+
(
1747+
!
1748+
ModuleObject
1749+
:
1750+
:
1751+
createSyntheticEnvironment
1752+
(
1753+
cx
1754+
moduleObject
1755+
exportValues
1756+
)
1757+
)
1758+
{
1759+
return
1760+
nullptr
1761+
;
1762+
}
1763+
return
1764+
moduleObject
1765+
;
1766+
}
1767+
JS_PUBLIC_API
16311768
void
16321769
JS
16331770
:
@@ -11283,6 +11420,52 @@ clearAsyncEvaluatingPostOrder
1128311420
(
1128411421
)
1128511422
;
11423+
if
11424+
(
11425+
module
11426+
-
11427+
>
11428+
hasTopLevelCapability
11429+
(
11430+
)
11431+
)
11432+
{
11433+
MOZ_ASSERT
11434+
(
11435+
module
11436+
-
11437+
>
11438+
getCycleRoot
11439+
(
11440+
)
11441+
=
11442+
=
11443+
module
11444+
)
11445+
;
11446+
if
11447+
(
11448+
!
11449+
ModuleObject
11450+
:
11451+
:
11452+
topLevelCapabilityReject
11453+
(
11454+
cx
11455+
module
11456+
error
11457+
)
11458+
)
11459+
{
11460+
cx
11461+
-
11462+
>
11463+
clearPendingException
11464+
(
11465+
)
11466+
;
11467+
}
11468+
}
1128611469
Rooted
1128711470
<
1128811471
ListObject
@@ -11360,52 +11543,6 @@ error
1136011543
)
1136111544
;
1136211545
}
11363-
if
11364-
(
11365-
module
11366-
-
11367-
>
11368-
hasTopLevelCapability
11369-
(
11370-
)
11371-
)
11372-
{
11373-
MOZ_ASSERT
11374-
(
11375-
module
11376-
-
11377-
>
11378-
getCycleRoot
11379-
(
11380-
)
11381-
=
11382-
=
11383-
module
11384-
)
11385-
;
11386-
if
11387-
(
11388-
!
11389-
ModuleObject
11390-
:
11391-
:
11392-
topLevelCapabilityReject
11393-
(
11394-
cx
11395-
module
11396-
error
11397-
)
11398-
)
11399-
{
11400-
cx
11401-
-
11402-
>
11403-
clearPendingException
11404-
(
11405-
)
11406-
;
11407-
}
11408-
}
1140911546
}
1141011547
static
1141111548
bool

0 commit comments

Comments
 (0)