Fix flutter web app not respecting assets path when in non-root folder#96774
Fix flutter web app not respecting assets path when in non-root folder#96774fluttergithubbot merged 3 commits intoflutter:masterfrom nicolasvac:master
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
I'm not sure where to look for writing a test or even how to, so if the PR reviewer could guide me that would help a lot. |
|
The change itself LGTM. Is there a way to write a test that would make sure we don't break it in the future? |
|
Maybe something like this? https://github.com/flutter/flutter/blob/master/dev/bots/service_worker_test.dart |
|
@yjbanov i think a test that checks if the '/' is present at the beginning of the file names is sufficient ? |
yjbanov
left a comment
There was a problem hiding this comment.
Nah, let's just remove this line. For the deployment scenarios that we formally support and already have tests for this line is unnecessary. However, it's worth fixing for other environments, even if we don't have a proper setup for replicating them in our tests. So I think a no-test exception is reasonable in this case.
|
Of course, since we don't have a test environment that replicates Github pages or similar, there's no guarantee that we won't break this again in the future. We won't break it on purpose though. |
ditman
left a comment
There was a problem hiding this comment.
Hm, webworkers should be scoped to the directory from where they're served, so this "/" should mean: "/baseDir/" and not the root directory of the domain itself.
See Parameters > options > scope: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register#parameters
Let's try this, but I think that if we remove this, we're breaking the offline mode for the "root" of the webapp.
Also, the restriction above can be removed by the server via a header, so maybe this is a matter of the serviceworker being misconfigured?:
"Servers can remove this restriction by setting a
Service-Worker-Allowedheader on the service worker script, and then you can specify a max scope for that service worker above the service worker's location."
|
(Just checked in the original issue, and the headers are not overriding service worker scopes, odd) |
|
For some reason I thought |
|
Well, our service worker does fetch it, but maybe that's unnecessary? We don't really support offline mode very easily right now, so all this may be a little moot. |
|
(I think this can be merged, but it'll need revisiting when solving the issue you linked for sure @yjbanov) |
|
@nicolasvac looks like there's a type error that the |
|
@christopherfujino how is this affected by removing the first element of the list, considering it's still a list ? |
I didn't actually look at your PR before. Now that I did...I have no idea |
|
I scheduled a re-run of |
|
@christopherfujino merged commits |
|
I'm stumped on this failure, gonna ask about it on the tests channel of our discord server. |
|
Ok, narrowed it down to an bug in the test file: #99522. I will submit a patch to fix. |
|
Fix is in #99524 |
Fix has been merged, @nicolasvac please rebase upstream. The test will still fail because you need to update an expectation, but the failure should tell you how to fix it. |
|
@christopherfujino i've remerged everything and waited for the tests to run, Still this is not related to this merge request. I hope this can be merged now as it has been over two months for "outside" problems |
Per the Flutter team's Tree Hygiene policy this change cannot be merged with failing tests. The customer_testing-linux test will be fixed by rebasing (not merging) upstream. As for the web test infrastructure failure, I am not familiar with that. I would recommend joining the discord #hackers-infra channel and following up there (alternatively you can file an issue for it). |
|
The failures seem unrelated to this PR and are probably caused by the branch being stale. @nicolasvac could you please try rebasing your branch on top of |

This pull request aims to fix #68449.
This bug is blocking the incremental integration of every flutter web-app in subdirectories for existing systems.
And also, because this bug makes every flutter web-app search in the root domain path for assets, it only allows for one flutter web-app to co-exists even if in different projects / directories.
List which issues are fixed by this PR. You must list at least one issue.
If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].
Pre-launch Checklist
///).