<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/node-new.git/src/node_api.cc, branch docs-fix</title>
<subtitle>github.com: nodejs/node.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/'/>
<entry>
<title>n-api: re-implement async env cleanup hooks</title>
<updated>2020-08-27T15:18:37+00:00</updated>
<author>
<name>Gabriel Schulhof</name>
<email>gabriel.schulhof@intel.com</email>
</author>
<published>2020-08-17T17:13:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=0848f56cb39432090cdb99af9b8541fbc1a2849c'/>
<id>0848f56cb39432090cdb99af9b8541fbc1a2849c</id>
<content type='text'>
* Avoid passing core `void*` and function pointers into add-on.
* Document `napi_async_cleanup_hook_handle` type.
* Render receipt of the handle mandatory from the point where the
  hook gets called. Removal of the handle remains mandatory.

Fixes: https://github.com/nodejs/node/issues/34715
Signed-off-by: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
Co-authored-by: Anna Henningsen &lt;github@addaleax.net&gt;
PR-URL: https://github.com/nodejs/node/pull/34819
Reviewed-By: Michael Dawson &lt;michael_dawson@ca.ibm.com&gt;
Reviewed-By: Zeyu Yang &lt;himself65@outlook.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Avoid passing core `void*` and function pointers into add-on.
* Document `napi_async_cleanup_hook_handle` type.
* Render receipt of the handle mandatory from the point where the
  hook gets called. Removal of the handle remains mandatory.

Fixes: https://github.com/nodejs/node/issues/34715
Signed-off-by: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
Co-authored-by: Anna Henningsen &lt;github@addaleax.net&gt;
PR-URL: https://github.com/nodejs/node/pull/34819
Reviewed-By: Michael Dawson &lt;michael_dawson@ca.ibm.com&gt;
Reviewed-By: Zeyu Yang &lt;himself65@outlook.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>n-api: fix use-after-free with napi_remove_async_cleanup_hook</title>
<updated>2020-08-07T18:25:42+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2020-08-07T10:48:45+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=262d0d0482ffd2fe7d654422df9df1f350045635'/>
<id>262d0d0482ffd2fe7d654422df9df1f350045635</id>
<content type='text'>
Fixes: https://github.com/nodejs/node/issues/34657
Refs: https://github.com/nodejs/node/pull/34572

PR-URL: https://github.com/nodejs/node/pull/34662
Reviewed-By: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes: https://github.com/nodejs/node/issues/34657
Refs: https://github.com/nodejs/node/pull/34572

PR-URL: https://github.com/nodejs/node/pull/34662
Reviewed-By: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>n-api,src: provide asynchronous cleanup hooks</title>
<updated>2020-08-06T22:02:02+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2020-07-31T00:10:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=22cbbcf9d9374d4b663bf1409f292212fa57623a'/>
<id>22cbbcf9d9374d4b663bf1409f292212fa57623a</id>
<content type='text'>
Sometimes addons need to perform cleanup actions, for example
closing libuv handles or waiting for requests to finish, that
cannot be performed synchronously.

Add C++ API and N-API functions that allow providing such
asynchronous cleanup hooks.

Fixes: https://github.com/nodejs/node/issues/34567

PR-URL: https://github.com/nodejs/node/pull/34572
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Sometimes addons need to perform cleanup actions, for example
closing libuv handles or waiting for requests to finish, that
cannot be performed synchronously.

Add C++ API and N-API functions that allow providing such
asynchronous cleanup hooks.

Fixes: https://github.com/nodejs/node/issues/34567

PR-URL: https://github.com/nodejs/node/pull/34572
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>n-api: run all finalizers via SetImmediate()</title>
<updated>2020-07-24T06:28:09+00:00</updated>
<author>
<name>Gabriel Schulhof</name>
<email>gabriel.schulhof@intel.com</email>
</author>
<published>2020-07-15T22:45:53+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=a74a6e3ba131752225a527d915593d7e413b1594'/>
<id>a74a6e3ba131752225a527d915593d7e413b1594</id>
<content type='text'>
Throwing an exception from a finalizer can cause the following fatal
error:

Error: async hook stack has become corrupted (actual: 2, expected: 0)
 1: 0x970b5a node::InternalCallbackScope::~InternalCallbackScope()
    [./node]
 2: 0x99dda0 node::Environment::RunTimers(uv_timer_s*) [./node]
 3: 0x13d8b22  [./node]
 4: 0x13dbe42 uv_run [./node]
 5: 0xa57974 node::NodeMainInstance::Run() [./node]
 6: 0x9dbc17 node::Start(int, char**) [./node]
 7: 0x7f4965417f43 __libc_start_main [/lib64/libc.so.6]
 8: 0x96f4ae _start [./node]

By https://github.com/nodejs/node/issues/34341#issuecomment-658426281,
calling into JS from a finalizer and/or throwing exceptions from there
is not advised, because the stack may or may not be set up for JS
execution. The best solution is to run the user's finalizer from a
`SetImmediate()` callback.

Signed-off-by: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
Fixes: https://github.com/nodejs/node/issues/34341
PR-URL: https://github.com/nodejs/node/pull/34386
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Michael Dawson &lt;michael_dawson@ca.ibm.com&gt;
Reviewed-By: Juan José Arboleda &lt;soyjuanarbol@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Throwing an exception from a finalizer can cause the following fatal
error:

Error: async hook stack has become corrupted (actual: 2, expected: 0)
 1: 0x970b5a node::InternalCallbackScope::~InternalCallbackScope()
    [./node]
 2: 0x99dda0 node::Environment::RunTimers(uv_timer_s*) [./node]
 3: 0x13d8b22  [./node]
 4: 0x13dbe42 uv_run [./node]
 5: 0xa57974 node::NodeMainInstance::Run() [./node]
 6: 0x9dbc17 node::Start(int, char**) [./node]
 7: 0x7f4965417f43 __libc_start_main [/lib64/libc.so.6]
 8: 0x96f4ae _start [./node]

By https://github.com/nodejs/node/issues/34341#issuecomment-658426281,
calling into JS from a finalizer and/or throwing exceptions from there
is not advised, because the stack may or may not be set up for JS
execution. The best solution is to run the user's finalizer from a
`SetImmediate()` callback.

Signed-off-by: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
Fixes: https://github.com/nodejs/node/issues/34341
PR-URL: https://github.com/nodejs/node/pull/34386
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Michael Dawson &lt;michael_dawson@ca.ibm.com&gt;
Reviewed-By: Juan José Arboleda &lt;soyjuanarbol@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>worker: add public method for marking objects as untransferable</title>
<updated>2020-06-25T15:33:29+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2020-06-19T18:39:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=88fb5a5c7933022de750745e51e5dc0996a1e2c4'/>
<id>88fb5a5c7933022de750745e51e5dc0996a1e2c4</id>
<content type='text'>
We currently mark a number of `ArrayBuffer`s as not transferable,
including the `Buffer` pool and ones with finalizers provided
by C++ addons.

There is no good reason to assume that userland code might not
encounter similar problems, for example when doing `ArrayBuffer`
pooling similar to ours. Therefore, provide an API that lets
userland code also mark objects as not transferable.

PR-URL: https://github.com/nodejs/node/pull/33979
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We currently mark a number of `ArrayBuffer`s as not transferable,
including the `Buffer` pool and ones with finalizers provided
by C++ addons.

There is no good reason to assume that userland code might not
encounter similar problems, for example when doing `ArrayBuffer`
pooling similar to ours. Therefore, provide an API that lets
userland code also mark objects as not transferable.

PR-URL: https://github.com/nodejs/node/pull/33979
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>n-api: remove `napi_env::CallIntoModuleThrow`</title>
<updated>2020-05-28T20:28:56+00:00</updated>
<author>
<name>Gabriel Schulhof</name>
<email>gabriel.schulhof@intel.com</email>
</author>
<published>2020-05-26T15:32:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=6a1df3b5afc92f438cf84621abd8cda79d9b1b17'/>
<id>6a1df3b5afc92f438cf84621abd8cda79d9b1b17</id>
<content type='text'>
Give `napi_env::CallIntoModule` the thrower used by
`CallIntoModuleThrow` as its default second argument. That way we do
not need two different methods on `napi_env` for calling into the
addon.

PR-URL: https://github.com/nodejs/node/pull/33570
Signed-off-by: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Chengzhong Wu &lt;legendecas@gmail.com&gt;
Reviewed-By: Michael Dawson &lt;michael_dawson@ca.ibm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Give `napi_env::CallIntoModule` the thrower used by
`CallIntoModuleThrow` as its default second argument. That way we do
not need two different methods on `napi_env` for calling into the
addon.

PR-URL: https://github.com/nodejs/node/pull/33570
Signed-off-by: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Chengzhong Wu &lt;legendecas@gmail.com&gt;
Reviewed-By: Michael Dawson &lt;michael_dawson@ca.ibm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "n-api: detect deadlocks in thread-safe function"</title>
<updated>2020-05-23T15:45:42+00:00</updated>
<author>
<name>Anna Henningsen</name>
<email>anna@addaleax.net</email>
</author>
<published>2020-05-18T04:50:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=b18d8dde847e1bff188c6cfb2d65a96209146c2c'/>
<id>b18d8dde847e1bff188c6cfb2d65a96209146c2c</id>
<content type='text'>
This reverts commit d26ca06c16f497ffa5ac4845a27922d5058a9318 because
it breaks running the tests in debug mode, as
`v8::Isolate::GetCurrent()` is not allowed if no `Isolate` is active
on the current thread.

Refs: https://github.com/nodejs/node/pull/33276
Refs: https://github.com/nodejs/node/pull/32860

PR-URL: https://github.com/nodejs/node/pull/33453
Reviewed-By: Daniel Bevenius &lt;daniel.bevenius@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
Reviewed-By: Gireesh Punathil &lt;gpunathi@in.ibm.com&gt;
Reviewed-By: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit d26ca06c16f497ffa5ac4845a27922d5058a9318 because
it breaks running the tests in debug mode, as
`v8::Isolate::GetCurrent()` is not allowed if no `Isolate` is active
on the current thread.

Refs: https://github.com/nodejs/node/pull/33276
Refs: https://github.com/nodejs/node/pull/32860

PR-URL: https://github.com/nodejs/node/pull/33453
Reviewed-By: Daniel Bevenius &lt;daniel.bevenius@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
Reviewed-By: Gireesh Punathil &lt;gpunathi@in.ibm.com&gt;
Reviewed-By: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>n-api: simplify uv_idle wrangling</title>
<updated>2020-04-29T01:53:59+00:00</updated>
<author>
<name>Ben Noordhuis</name>
<email>info@bnoordhuis.nl</email>
</author>
<published>2020-04-22T08:50:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=eebf52d27950afc271ede949b2ea055c83e1867f'/>
<id>eebf52d27950afc271ede949b2ea055c83e1867f</id>
<content type='text'>
uv_idle_init(), uv_idle_start() and uv_idle_stop() always succeed.
Remove the superfluous error handling.

Refs: https://github.com/libuv/libuv/pull/2803

PR-URL: https://github.com/nodejs/node/pull/32997
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
Reviewed-By: Juan José Arboleda &lt;soyjuanarbol@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
uv_idle_init(), uv_idle_start() and uv_idle_stop() always succeed.
Remove the superfluous error handling.

Refs: https://github.com/libuv/libuv/pull/2803

PR-URL: https://github.com/nodejs/node/pull/32997
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: David Carlier &lt;devnexen@gmail.com&gt;
Reviewed-By: Gus Caplan &lt;me@gus.host&gt;
Reviewed-By: Juan José Arboleda &lt;soyjuanarbol@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>n-api: detect deadlocks in thread-safe function</title>
<updated>2020-04-19T17:07:00+00:00</updated>
<author>
<name>Gabriel Schulhof</name>
<email>gabriel.schulhof@intel.com</email>
</author>
<published>2020-04-06T17:16:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=d26ca06c16f497ffa5ac4845a27922d5058a9318'/>
<id>d26ca06c16f497ffa5ac4845a27922d5058a9318</id>
<content type='text'>
We introduce status `napi_would_deadlock` to be used as a return status
by `napi_call_threadsafe_function` if the call is made with
`napi_tsfn_blocking` on the main thread and the queue is full.

Fixes: https://github.com/nodejs/node/issues/32615
Signed-off-by: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
PR-URL: https://github.com/nodejs/node/pull/32860
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: Michael Dawson &lt;michael_dawson@ca.ibm.com&gt;
Reviewed-By: Zeyu Yang &lt;himself65@outlook.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We introduce status `napi_would_deadlock` to be used as a return status
by `napi_call_threadsafe_function` if the call is made with
`napi_tsfn_blocking` on the main thread and the queue is full.

Fixes: https://github.com/nodejs/node/issues/32615
Signed-off-by: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
PR-URL: https://github.com/nodejs/node/pull/32860
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: Michael Dawson &lt;michael_dawson@ca.ibm.com&gt;
Reviewed-By: Zeyu Yang &lt;himself65@outlook.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "n-api: detect deadlocks in thread-safe function"</title>
<updated>2020-04-16T19:52:12+00:00</updated>
<author>
<name>Gabriel Schulhof</name>
<email>gabriel.schulhof@intel.com</email>
</author>
<published>2020-04-16T14:23:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=d3d5eca657474f25fab47036fef9469efc211d8a'/>
<id>d3d5eca657474f25fab47036fef9469efc211d8a</id>
<content type='text'>
This reverts commit aeb7084fe6446350ec032e9819746126811bf44f.

The solution creates incorrect behaviour on Windows.

Re: https://github.com/nodejs/node-addon-api/pull/697#issuecomment-612993476
Signed-off-by: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
PR-URL: https://github.com/nodejs/node/pull/32880
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Gireesh Punathil &lt;gpunathi@in.ibm.com&gt;
Reviewed-By: Chengzhong Wu &lt;legendecas@gmail.com&gt;
Reviewed-By: Gerhard Stöbich &lt;deb2001-github@yahoo.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit aeb7084fe6446350ec032e9819746126811bf44f.

The solution creates incorrect behaviour on Windows.

Re: https://github.com/nodejs/node-addon-api/pull/697#issuecomment-612993476
Signed-off-by: Gabriel Schulhof &lt;gabriel.schulhof@intel.com&gt;
PR-URL: https://github.com/nodejs/node/pull/32880
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Gireesh Punathil &lt;gpunathi@in.ibm.com&gt;
Reviewed-By: Chengzhong Wu &lt;legendecas@gmail.com&gt;
Reviewed-By: Gerhard Stöbich &lt;deb2001-github@yahoo.de&gt;
</pre>
</div>
</content>
</entry>
</feed>
