Skip to content

Commit 60025bd

Browse files
aduh95targos
authored andcommitted
doc: add note regarding unfinished TLA
PR-URL: #41434 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 10bdb59 commit 60025bd

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

doc/api/esm.md

+23-5
Original file line numberDiff line numberDiff line change
@@ -590,15 +590,16 @@ would provide the exports interface for the instantiation of `module.wasm`.
590590
591591
## Top-level `await`
592592
593+
<!--
594+
added: v14.8.0
595+
-->
596+
593597
> Stability: 1 - Experimental
594598
595-
The `await` keyword may be used in the top level (outside of async functions)
596-
within modules as per the [ECMAScript Top-Level `await` proposal][].
599+
The `await` keyword may be used in the top level body of an ECMAScript module.
597600
598601
Assuming an `a.mjs` with
599602
600-
<!-- eslint-skip -->
601-
602603
```js
603604
export const five = await Promise.resolve(5);
604605
```
@@ -615,6 +616,23 @@ console.log(five); // Logs `5`
615616
node b.mjs # works
616617
```
617618
619+
If a top level `await` expression never resolves, the `node` process will exit
620+
with a `13` [status code][].
621+
622+
```js
623+
import { spawn } from 'child_process';
624+
import { execPath } from 'process';
625+
626+
spawn(execPath, [
627+
'--input-type=module',
628+
'--eval',
629+
// Never-resolving Promise:
630+
'await new Promise(() => {})',
631+
]).once('exit', (code) => {
632+
console.log(code); // Logs `13`
633+
});
634+
```
635+
618636
<i id="esm_experimental_loaders"></i>
619637
620638
## Loaders
@@ -1425,7 +1443,6 @@ success!
14251443
[Conditional exports]: packages.md#conditional-exports
14261444
[Core modules]: modules.md#core-modules
14271445
[Dynamic `import()`]: https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports
1428-
[ECMAScript Top-Level `await` proposal]: https://github.com/tc39/proposal-top-level-await/
14291446
[ES Module Integration Proposal for WebAssembly]: https://github.com/webassembly/esm-integration
14301447
[Import Assertions]: #import-assertions
14311448
[Import Assertions proposal]: https://github.com/tc39/proposal-import-assertions
@@ -1460,5 +1477,6 @@ success!
14601477
[percent-encoded]: url.md#percent-encoding-in-urls
14611478
[resolve hook]: #resolvespecifier-context-defaultresolve
14621479
[special scheme]: https://url.spec.whatwg.org/#special-scheme
1480+
[status code]: process.md#exit-codes
14631481
[the official standard format]: https://tc39.github.io/ecma262/#sec-modules
14641482
[url.pathToFileURL]: url.md#urlpathtofileurlpath

0 commit comments

Comments
 (0)