-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Manifest V3 declarativeNetRequest redirect sample is completely broken on latest chrome 121 #1082
Comments
Thanks for opening the issue! DNR is not broken in Chrome 121, the site that the code is redirecting has gone through massive changes since the example was made. Specifically, it looks like the trailing slash on the matching domain is causing a problem. A change in the server's response handling can cause that. |
Thanks, olokos and patrickkettner. I also find something interesting:
|
Your "fix" does absolutely nothing, which I've tested before even writing this issue. I've tested it now again and #1083 doesn't change anything at all. Extensions are usually meant to affect websites that the extension developer has no control over, otherwise the server owner/developer would implement such functionality on the server's backend, making the extension completely useless and very inefficient. If a simple redirect from one domain to another cannot be done with the browser extension and requires server specific backend changes, then this only confirms that this functionality is broken at its core - on a stable chrome build. I'm not using beta or canary, on which that would be expected. This makes it clear to me that currently either chrome or manifest v3 is non-functional and it seems like no fixing of the samples is going to change anything, as I was trying to achieve any sort of block or redirect last night and none of the functions related to block/redirect a website in the documentation have any effect, no errors, but no action taken. Such a simple and core functionality, as redirect from a to b is completely and fundamentally broken, to the extent where even the official samples and documentation is non-functional. This does not make Google Chrome manifest V3 feel like it's made by the Tech Giant that Google is, taking over 70% of web browsers market share, planning to force everybody to Manifest V3 in June of 2024, but instead this makes me feel like I'm commenting on some issue on some small browser startup project, made by college students in 15-minute breaks between classes, where the project started just a week ago and is still a buggy mess. |
I've closed Chrome completely in task manager to start fresh after installing the sample extension, it does claim it started the service worker, but nothing happens. I confirm that @zhouhao 's workaround of manually allowing the extension to run in incognito mode and then opening the mv2 website in incognito, does result in the redirect, but that's just a workaround, not a solution, the regular profiles mv3 redirect remains in a broken state as of today and the current version of "Stable" Chrome. Making a change server side so the sample works, would only be a workaround of the problem, on the same level as running the extension in incognito to have it work in the first place. Which makes me believe that the issue indeed lies in the Manifest V3 or the Chrome browser itself. Issues I listed above are still current and ongoing, please kindly let us know here, if there's any progress. |
I had a brief look at this. It seems like as part of the move to new infrastructure @patrickkettner mentioned, we started using a service worker to handle requests. The rules in this sample are explicitly filtered to only work on In this specific case, it seems like removing the That isn't a great solution generally though, since most sites don't have a service worker and would actually need the @olokos We'll look at fixing this, but in the meantime, removing the |
Thanks for the explanation on what's going on here @oliverdunk So if I understood correctly, the issue is that the redirect needs some arbitrary elements from the server response? In the coming fix, could we have it work in the simplest - website content independent way? So: With no additional checks of whats on site A or downloading from it, so the redirect would not even access the A.com or send any dns queries, making it a true redirect from an extension. With regards to HTTP/3 coming, the entire sea of web development frameworks and different ways to run the site, I think relying on specific page components, is bound to break at some point, as we can see already. |
I may be misunderstanding what you're saying but I think it's slightly different. Service workers allow a site to say "when a user tries to load my site, don't do what you'd normally do - just run this JS which returns a response". So a valid service worker could look like this: self.addEventListener('fetch', function(event) {
return new Response(JSON.stringify({ hello: 'world' }), {
headers: {'Content-Type': 'application/json'}
});
}); In that case, should DNR rules apply when you try to load the site? DNR works at the network level and nothing ever happened on the network, so probably not - although in some cases this could be useful. Without having looked at the code on https://developer.chrome.com/, I suspect it looks something like this: self.addEventListener('fetch', function(event) {
// Some other logic...
return fetch(event.request);
}); In that case:
Hopefully that all makes sense? The hard balance here is that it would never be possible to block all "requests" made by all frameworks because they do a lot of trickery. In some cases, the new page may be generated entirely in JS and the network is never hit. So (even in Manifest V2) there are some limitations to what an extension can block generically without an understanding of how a specific site works. |
Thanks, that does explain quite a lot in how it all works, appreciate it. I have removed the resourceTypes section from the
|
Right. The default value is
Yeah, I think either that or we just update the sample to use a site without a service worker. We need to decide between covering a few more of the cases or keeping it simple.
It would work for both of these cases. There are still cases where a website could load without DNR applying, for example if the service worker is able to serve the page without making any network requests using local data it has stored. It should be rare, but is worth knowing. |
Thanks, that does seem promising, looking forwards for an update with a fix, I hope it will be an update in chrome that will cover both of those scenarios, not just a sample update, as that woud require duplicate entries for each website, if the site content is not known. I remember that MV2 did support http, https, websocket and secure websocket So I guess we're not going to be able to redirect the websockets, even after the fix? |
I don't expect we will make any changes in Chrome based on this. You should be able to have a single entry with two resource types specified.
There's also a "websocket" resource type you can use :) |
Describe the bug
The declarativeNetRequest redirect does not do anything, sevice worker doesn't react and the browser behaves as if there's no extension at all, not redirecting anywhere.
To Reproduce
Steps to reproduce the behavior, or file the issue is found in:
Expected behavior
Should redirect to:
https://developer.chrome.com/docs/extensions/mv3/intro/
Notes
I believe that Manifest V3 declarativeNetRequest API is currently completely broken and inactive.
Maybe it's a bug with Chrome itself?
Tested on chrome 121.0.6167.185
The text was updated successfully, but these errors were encountered: