node-addon-examples icon indicating copy to clipboard operation
node-addon-examples copied to clipboard

Improve `AsyncWorker` example handling `Object/Buffer/Uint8Array` as parameter

Open mahnunchik opened this issue 1 year ago • 2 comments

Hello,

I've created issue in node-addon-api https://github.com/nodejs/node-addon-api/issues/1453 but it may be related more to scope of this repository.

I couldn't find in the documentation and examples how to properly handle Object/Buffer/Uint8Array parameters in AsyncWorker?

https://github.com/nodejs/node-addon-api/issues/1453

mahnunchik avatar Feb 21 '24 05:02 mahnunchik

I believe https://github.com/nodejs/node-addon-examples/tree/main/src/4-references-and-handle-scope/function-reference-demo/node-addon-api can be a good example to prevent objects from being reclaimed by the garbage collector.

legendecas avatar Mar 05 '24 07:03 legendecas

Yes it is good starting point, but working with AsyncWorker is a bit different because it was not clear to me where to wrap and where to release data. Now it is clear for me https://github.com/nodejs/node-addon-api/issues/1453#issuecomment-1970549421 but I think example can be added.

mahnunchik avatar Mar 05 '24 17:03 mahnunchik