Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Avoid HMR crash when src is undefined#508

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ro-savage wants to merge1 commit intowebpack-contrib:master
base:master
Choose a base branch
Loading
fromro-savage:fix-getCurrentScriptUrl-guard

Conversation

ro-savage
Copy link

This PR contains a:

  • bugfix
  • newfeature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

The function returned bygetCurrentScriptUrl usually returns an array. However when!src is true it returnsnull.

This causes a crash whengetReloadUrl() is run and tries to execute src.some((url) =>)

https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/hmr/hotModuleReplacement.js#L137

This instead returns an empty array instead so that it can always safely be assumed that an array will be returned.

I couldn't find any reason to returnnull instead, but if there is a reason. Another option would be to have a guard before or insidereloadStyle.

Breaking Changes

None that I am aware of.

Additional Info

Log from our setup. This happens every time we change a CSS file, and occasionally when just changing a JS file.

hotModuleReplacement.js:130 Uncaught TypeError: Cannot read property 'some' of null    at getReloadUrl (hotModuleReplacement.js:130)    at hotModuleReplacement.js:148    at NodeList.forEach (<anonymous>)    at reloadStyle (hotModuleReplacement.js:142)    at update (hotModuleReplacement.js:197)    at functionCall (hotModuleReplacement.js:24)getReloadUrl @ hotModuleReplacement.js:130(anonymous) @ hotModuleReplacement.js:148reloadStyle @ hotModuleReplacement.js:142update @ hotModuleReplacement.js:197functionCall @ hotModuleReplacement.js:24setTimeout (async)(anonymous) @ hotModuleReplacement.js:28hotApply @ bootstrap:607(anonymous) @ bootstrap:362Promise.then (async)hotUpdateDownloaded @ bootstrap:361hotAddUpdateChunk @ bootstrap:337webpackHotUpdateCallback @ bootstrap:57(anonymous) @ application-874885fd2d95998bf4fc.hot-update.js:1

@jsf-clabot
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign ourContributor License Agreement before we can accept your contribution.

Copy link
Member

@alexander-akaitalexander-akait left a comment

Choose a reason for hiding this comment

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

Can you add test or create reproducible test repo and I will write test

@ro-savage
Copy link
Author

ro-savage commentedMar 13, 2020
edited
Loading

Unfortunately, I haven't been able to track down why we hithttps://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/hmr/hotModuleReplacement.js#L54 and havenull returned. So I haven't been able to create a demo repo (we are using rails andwebpacker to run webpack).

However, if you reach L54 for any reason then it will crash the webpack becausehttps://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/hmr/hotModuleReplacement.js#L137 will always throw an error trying to runnnull.some().

It appears null is the incorrect thing to return when no src is found, instead an empty array makes more sense.

@AntonioRedondo
Copy link

AntonioRedondo commentedApr 18, 2020
edited
Loading

Any progress on this PR? I'm experiencing the error and sadly it prevents me to hot reload styling. 😢

@ro-savage
Copy link
Author

@AntonioRedondo - I run a forked version now, since this hasn't been fixed. Given the fact this does fix it, and null is obviously incorrect since later on it runs.some() on the value. I don't know why this hasn't been fixed/merged. Regardless of the test case or not, you can literally just read the code and see this path will always throw.@evilebottnawi

You can run the forked version as
"mini-css-extract-plugin": "npm:@ro-savage/mini-css-extract-plugin",

@lgollut
Copy link

We experience that as well with somevue component that dosen't contains any style section... Will try to track down a little if I can

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@alexander-akaitalexander-akaitalexander-akait requested changes

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@ro-savage@jsf-clabot@AntonioRedondo@lgollut@alexander-akait

[8]ページ先頭

©2009-2025 Movatter.jp