diff --git a/platform/nodejs/index.js b/platform/nodejs/index.js index e7282f8f8..a1ec68ea6 100644 --- a/platform/nodejs/index.js +++ b/platform/nodejs/index.js @@ -95,7 +95,10 @@ function pslInit(raw) { return globals.publicSuffixList; } - raw = readFileSync(resolve(__dirname, './assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat'), 'utf8') + raw = readFileSync( + resolve(__dirname, './assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat'), + 'utf8' + ); if ( typeof raw !== 'string' || raw.trim() === '' ) { console.error('Unable to populate public suffix list'); return; @@ -147,7 +150,7 @@ async function useLists(lists, options = {}) { snfe.reset(); if ( Array.isArray(lists) === false || lists.length === 0 ) { - return snfe; + return; } let compiler = null; @@ -176,8 +179,6 @@ async function useLists(lists, options = {}) { // Commit changes snfe.freeze(); snfe.optimize(); - - return snfe; } /******************************************************************************/ @@ -253,9 +254,10 @@ class StaticNetFilteringEngine { return instance; } - static release() { - useLists([]); + static async release() { + if ( snfeProxyInstance === null ) { return; } snfeProxyInstance = null; + await useLists([]); } }