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

too many reloads, is my delay ignored? #55

Closed
anvlkv opened this issue Nov 26, 2019 · 17 comments
Closed

too many reloads, is my delay ignored? #55

anvlkv opened this issue Nov 26, 2019 · 17 comments

Comments

@anvlkv
Copy link

anvlkv commented Nov 26, 2019

I've set a delay already

new LiveReloadPlugin({
            appendScriptTag: true,
            delay: 3000
        })

and

watchOptions: {
        aggregateTimeout: 300,
        ignored: ['node_modules']
    },

Still my browser tries to reload 30 times and cancels the request.

@statianzo
Copy link
Owner

What do you mean by "cancels the request"?

Could you make an example repo with the issue?

@infabo
Copy link

infabo commented Jan 20, 2020

Same here

@infabo
Copy link

infabo commented Jan 20, 2020

What do you mean by "cancels the request"?

open network panel in chromium and there you can see these cancelled requests.

@web-mi
Copy link
Collaborator

web-mi commented Feb 14, 2020

I got the same problem.
But the delay is working. It just notifies once after delay but the assets are getting reloaded multiple times with a new ?livereload= get parameter.
Maybe the appendScriptTag option is the problem?
Tried without appendScriptTag and got the same error.

@statianzo
Copy link
Owner

If you could share an example repository with the problem, I'd be glad to take a look.

@web-mi
Copy link
Collaborator

web-mi commented Feb 14, 2020

I digged into it and found the problem.
Every file which is not a css or image file will trigger a browser reload in tiny-lr. (Note: for every single file)

If you add the following configuration to your LiveReloadPlugin options it will trigger a reload for every file changed expecting css and image files:

new LiveReloadPlugin({
    liveCSS: false,
    liveImg: false,
})

The problem happens if you build multiple files in your webpack configuration:

module.exports = {
    entry: {
        first: [
            './js/first.js',
            './js/first.css',
        ],
        second: [
            './js/second.js',
            './js/second.css',
        ],
        third: [
            './js/third.js',
            './js/third.css',
        ],
    },
    // ...
};

This will create/renew the following assets at once and will trigger them as changed in webpack watch:
(Don't know why it rebuilds everything if i just changing first.js for example)
assets/first.js
assets/first.css
assets/first.js.map
assets/second.js
assets/second.css
assets/second.js.map
assets/third.js
assets/third.css
assets/third.js.map

Every single file will now trigger a file reload or page reload depending on the configuration.
And every new request will kill the previous one which will result in the high load and the failing requests in the console.

Currently i don't know a good solution.
notifyClients needs any files to trigger a reload.
For js you could just always give a non existing .js file and it will reload but thats a really bad solution.
There is a open PR for just sending changed files. Maybe this will work with this webpack configuration?

@web-mi
Copy link
Collaborator

web-mi commented Feb 14, 2020

I found this issue for multiple files rebuilds so maybe the first solution will be fixing the multiple created files.
webpack/webpack#7007

@web-mi
Copy link
Collaborator

web-mi commented Feb 16, 2020

#59 Should add the ablity to fix all problems by setting useSourceHash to true

@vishal9p
Copy link

vishal9p commented Aug 4, 2021

@web-mi please can you merge the change in webpack 5.

@web-mi
Copy link
Collaborator

web-mi commented Aug 4, 2021

@vishal9p Everything should already been merged into the latest version.

@vishal9p
Copy link

vishal9p commented Aug 4, 2021

@vishal9p Everything should already been merged into the latest version.

@web-mi still i can see the issue i am using latest webpack 5

You mentioned there is one open PR which is for just sending changed files.please can you share it

And for me i cannot use useSourceHash facing some other issue saying content and map not valid

@web-mi
Copy link
Collaborator

web-mi commented Aug 4, 2021

I think i mean the #33 but it should be required anymore.
Maybe with the latest changes useShourceHash gets broken? Could you share your error?

And could you try useSouceSize instead?

@vishal9p
Copy link

vishal9p commented Aug 4, 2021

I think i mean the #33 but it should be required anymore.
Maybe with the latest changes useShourceHash gets broken? Could you share your error?

And could you try useSouceSize instead?

@web-mi it worked with useSouceSize.
But this changes are not present in 3.0.1 so please can you publish your changes with new version maybe 3.0.2

@web-mi
Copy link
Collaborator

web-mi commented Aug 4, 2021

You mean the changes from #33 are not present in 3.0.1? These changes are not required anymore because of the new options useSourceHash and useSourceSize.

@vishal9p
Copy link

vishal9p commented Aug 4, 2021

useSourceHash

In 3.0.1 in index.js we are not seeing useSourceSize prop.but this is present in master.I think you need to publish a newer version

@web-mi
Copy link
Collaborator

web-mi commented Aug 4, 2021

Ahh sorry. You are right. The latest change not published.
Maybe in the latest version useSouceHash is already working again.

@statianzo Could you publish a new version with the latest changes?

@statianzo
Copy link
Owner

Released as 3.0.2

https://unpkg.com/browse/[email protected]/index.js

@anvlkv anvlkv closed this as completed Apr 22, 2024
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

No branches or pull requests

5 participants