Skip to content

Commit

Permalink
doc: clarify that ObjectWrap requires manual cleanup on shutdown
Browse files Browse the repository at this point in the history
Clarify that ObjectWrap instances are not destroyed on process or
worker shutdown and require manual destruction to avoid resource
leaks.

PR-URL: #40074
Fixes: #38816
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Flarna authored and BethGriggs committed Sep 21, 2021
1 parent 0df47d5 commit 81cb14b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/api/addons.md
Expand Up @@ -965,6 +965,10 @@ provided by the underlying V8 JavaScript engine. They are subject to change
or removal at any time. They are not documented by Node.js or V8, and they
should never be used outside of testing.

During shutdown of the process or worker threads destructors are not called
by the JS engine. Therefore it's the responsibility of the user to track
these objects and ensure proper destruction to avoid resource leaks.

### Factory of wrapped objects

Alternatively, it is possible to use a factory pattern to avoid explicitly
Expand Down

0 comments on commit 81cb14b

Please sign in to comment.