ajax-hook icon indicating copy to clipboard operation
ajax-hook copied to clipboard

avoid memory leakage and circular reference

Open cyfung1031 opened this issue 1 year ago • 1 comments

  • avoid memory leakage (release xhr after XMLHttpRequest.DONE)
  • avoid circular reference
  • resolve #116 & resolve #95 - JSON.stringify would bypass property xhr

Note: since xhr is set to null in config after xhr.readyState becomes 4, config.xhr will be null in async function inside onResponse.

onResponse: function(response, handler){
     ...
      const config = response.config;
      if(config.xhr.readyState  === XMLHttpRequest.DONE){
           setTimeout(()=>{
               console.log('config.xhr === null', config.xhr===null);
          }, 100)
      }
     ...
     handler.resolve(response);
}

cyfung1031 avatar Aug 16 '23 10:08 cyfung1031

Combined Distribution Script ajaxhook.js for Testing (PR 119, 120, 121, 122) https://cdn.jsdelivr.net/gh/cyfung1031/ajax-hook@1ebe48e08108449669290a226e52fc6fbf7ec9ef/dist/ajaxhook.js

cyfung1031 avatar Aug 16 '23 15:08 cyfung1031