On this page

    M

    process.finalization.registerBeforeExit

    History
    process.finalization.registerBeforeExit(ref, callback): void
    Stability: 1.1Active Development
    Attributes
    The reference to the resource that is being tracked.
    callback:Function
    The callback function to be called when the resource is finalized.
    The reference to the resource that is being tracked.
    event:string
    The event that triggered the finalization. Defaults to 'beforeExit'.

    This function behaves exactly like the register, except that the callback will be called when the process emits the beforeExit event if ref object was not garbage collected.

    Be aware that all limitations applied to the beforeExit event are also applied to the callback function, this means that there is a possibility that the callback will not be called under special circumstances.