Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: onerror mem leak #640

Merged
merged 3 commits into from
Oct 27, 2020
Merged

Conversation

dgeibi
Copy link
Contributor

@dgeibi dgeibi commented Oct 26, 2020

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

Fixes #639

Breaking Changes

No

Additional Info

No

@jsf-clabot
Copy link

jsf-clabot commented Oct 26, 2020

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Oct 26, 2020

Codecov Report

Merging #640 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #640   +/-   ##
=======================================
  Coverage   89.55%   89.55%           
=======================================
  Files          11       11           
  Lines         651      651           
  Branches      181      181           
=======================================
  Hits          583      583           
  Misses         65       65           
  Partials        3        3           
Impacted Files Coverage Δ
src/CssLoadingRuntimeModule.js 97.05% <ø> (ø)
src/index.js 91.35% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f448ee1...13bf471. Read the comment docs.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgeibi
Copy link
Contributor Author

dgeibi commented Oct 26, 2020

@evilebottnawi Do you mean I should add this line "prev(event)" ?

@alexander-akait
Copy link
Member

We should move onerror handler to separate function and handle this (look at link), we should generate runtime as little as possible

@dgeibi
Copy link
Contributor Author

dgeibi commented Oct 26, 2020

Is the generated code ok like this?

var onStyleComplete = function (event) {
  // avoid mem leaks
  linkTag.onerror = linkTag.onload = null;
  if (event.type === 'load') {
    resolve();
  } else {
    var request = (event && event.target && event.target.href) || fullhref;
    var err = new Error(
      'Loading CSS chunk ' + chunkId + ' failed.\n(' + request + ')'
    );
    err.code = 'CSS_CHUNK_LOAD_FAILED';
    err.request = request;
    linkTag.parentNode.removeChild(linkTag);
    reject(err);
  }
};
linkTag.onerror = linkTag.onload = onStyleComplete;

@alexander-akait
Copy link
Member

Yes 👍

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, thanks

@alexander-akait alexander-akait merged commit 2b6fcf2 into webpack-contrib:master Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onerror memory leak
3 participants