Skip to content

Commit 48b5c11

Browse files
author
Gabriel Schulhof
committed
n-api: update documentation
Document which APIs work while an exception is pending. This is the list of all APIs which do not start with `NAPI_PREAMBLE(env)`. Fixes: nodejs/abi-stable-node#257 PR-URL: nodejs#19078 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 9759573 commit 48b5c11

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

doc/api/n-api.md

+26-10
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ Do not rely on the content or format of any of the extended information as it
279279
is not subject to SemVer and may change at any time. It is intended only for
280280
logging purposes.
281281

282+
This API can be called even if there is a pending JavaScript exception.
283+
282284

283285
### Exceptions
284286
Any N-API function call may result in a pending JavaScript exception. This is
@@ -504,7 +506,6 @@ Returns `napi_ok` if the API succeeded.
504506

505507
This API returns a JavaScript RangeError with the text provided.
506508

507-
508509
#### napi_get_and_clear_last_exception
509510
<!-- YAML
510511
added: v8.0.0
@@ -521,6 +522,8 @@ Returns `napi_ok` if the API succeeded.
521522

522523
This API returns true if an exception is pending.
523524

525+
This API can be called even if there is a pending JavaScript exception.
526+
524527
#### napi_is_exception_pending
525528
<!-- YAML
526529
added: v8.0.0
@@ -536,6 +539,8 @@ Returns `napi_ok` if the API succeeded.
536539

537540
This API returns true if an exception is pending.
538541

542+
This API can be called even if there is a pending JavaScript exception.
543+
539544
### Fatal Errors
540545

541546
In the event of an unrecoverable error in a native module, a fatal error can be
@@ -562,6 +567,8 @@ null-terminated.
562567

563568
The function call does not return, the process will be terminated.
564569

570+
This API can be called even if there is a pending JavaScript exception.
571+
565572
## Object Lifetime management
566573

567574
As N-API calls are made, handles to objects in the heap for the underlying
@@ -683,6 +690,8 @@ Returns `napi_ok` if the API succeeded.
683690
This API closes the scope passed in. Scopes must be closed in the
684691
reverse order from which they were created.
685692

693+
This API can be called even if there is a pending JavaScript exception.
694+
686695
#### napi_open_escapable_handle_scope
687696
<!-- YAML
688697
added: v8.0.0
@@ -717,6 +726,8 @@ Returns `napi_ok` if the API succeeded.
717726
This API closes the scope passed in. Scopes must be closed in the
718727
reverse order from which they were created.
719728

729+
This API can be called even if there is a pending JavaScript exception.
730+
720731
#### napi_escape_handle
721732
<!-- YAML
722733
added: v8.0.0
@@ -740,7 +751,10 @@ This API promotes the handle to the JavaScript object so that it is valid
740751
for the lifetime of the outer scope. It can only be called once per scope.
741752
If it is called more than once an error will be returned.
742753

754+
This API can be called even if there is a pending JavaScript exception.
755+
743756
### References to objects with a lifespan longer than that of the native method
757+
744758
In some cases an addon will need to be able to create and reference objects
745759
with a lifespan longer than that of a single native method invocation. For
746760
example, to create a constructor and later use that constructor
@@ -815,6 +829,8 @@ Returns `napi_ok` if the API succeeded.
815829

816830
This API deletes the reference passed in.
817831

832+
This API can be called even if there is a pending JavaScript exception.
833+
818834
#### napi_reference_ref
819835
<!-- YAML
820836
added: v8.0.0
@@ -833,7 +849,6 @@ Returns `napi_ok` if the API succeeded.
833849
This API increments the reference count for the reference
834850
passed in and returns the resulting reference count.
835851

836-
837852
#### napi_reference_unref
838853
<!-- YAML
839854
added: v8.0.0
@@ -852,7 +867,6 @@ Returns `napi_ok` if the API succeeded.
852867
This API decrements the reference count for the reference
853868
passed in and returns the resulting reference count.
854869

855-
856870
#### napi_get_reference_value
857871
<!-- YAML
858872
added: v8.0.0
@@ -1667,8 +1681,6 @@ This API returns various properties of a typed array.
16671681
*Warning*: Use caution while using this API since the underlying data buffer
16681682
is managed by the VM
16691683

1670-
1671-
16721684
#### napi_get_dataview_info
16731685
<!-- YAML
16741686
added: v8.3.0
@@ -1696,7 +1708,6 @@ Returns `napi_ok` if the API succeeded.
16961708

16971709
This API returns various properties of a DataView.
16981710

1699-
17001711
#### napi_get_value_bool
17011712
<!-- YAML
17021713
added: v8.0.0
@@ -1737,7 +1748,6 @@ in it returns `napi_number_expected`.
17371748
This API returns the C double primitive equivalent of the given JavaScript
17381749
Number.
17391750

1740-
17411751
#### napi_get_value_external
17421752
<!-- YAML
17431753
added: v8.0.0
@@ -1799,7 +1809,7 @@ Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
17991809
is passed in it returns `napi_number_expected`.
18001810

18011811
This API returns the C int64 primitive equivalent of the given
1802-
JavaScript Number
1812+
JavaScript Number.
18031813

18041814
#### napi_get_value_string_latin1
18051815
<!-- YAML
@@ -2191,8 +2201,6 @@ Returns `napi_ok` if the API succeeded.
21912201

21922202
This API checks if the Object passsed in is a typed array.
21932203

2194-
2195-
21962204
### napi_is_dataview
21972205
<!-- YAML
21982206
added: v8.3.0
@@ -3308,6 +3316,8 @@ Returns `napi_ok` if the API succeeded.
33083316

33093317
This API frees a previously allocated work object.
33103318

3319+
This API can be called even if there is a pending JavaScript exception.
3320+
33113321
### napi_queue_async_work
33123322
<!-- YAML
33133323
added: v8.0.0
@@ -3346,6 +3356,8 @@ the `complete` callback will be invoked with a status value of
33463356
`napi_cancelled`. The work should not be deleted before the `complete`
33473357
callback invocation, even if it has been successfully cancelled.
33483358

3359+
This API can be called even if there is a pending JavaScript exception.
3360+
33493361
## Custom Asynchronous Operations
33503362
The simple asynchronous work APIs above may not be appropriate for every
33513363
scenario. When using any other asynchronous mechanism, the following APIs
@@ -3387,6 +3399,8 @@ napi_status napi_async_destroy(napi_env env,
33873399

33883400
Returns `napi_ok` if the API succeeded.
33893401

3402+
This API can be called even if there is a pending JavaScript exception.
3403+
33903404
### napi_make_callback
33913405
<!-- YAML
33923406
added: v8.0.0
@@ -3469,6 +3483,8 @@ NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env,
34693483
- `[in] env`: The environment that the API is invoked under.
34703484
- `[in] scope`: The scope to be closed.
34713485

3486+
This API can be called even if there is a pending JavaScript exception.
3487+
34723488
## Version Management
34733489

34743490
### napi_get_node_version

0 commit comments

Comments
 (0)