webdev icon indicating copy to clipboard operation
webdev copied to clipboard

baseUrl has the wrong value because app path has "/test/" in it

Open mdebbar opened this issue 2 years ago • 8 comments

Here is the relevant code that was copied to dwds. Here is the code in dwds: https://github.com/dart-lang/webdev/blob/3ad544e2c4d4dff5a4cb3e059f72cf075c156288/dwds/lib/src/loaders/require.dart#L36-L46

We got a report from a user seeing this issue (and I was able to reproduce it, too): https://github.com/flutter/flutter/issues/116360#issuecomment-1431243464

Basically, their app has a path "/sample_item/test/", it trips the generated bootstrap code into thinking that it's in test mode, and it calculates the wrong baseUrl.

mdebbar avatar Feb 15 '23 16:02 mdebbar

I didn't think flutter was still using build_web_compilers?

jakemac53 avatar Feb 15 '23 18:02 jakemac53

I didn't think flutter was still using build_web_compilers?

Hmmm.. I'm not sure. We do generate main_module.bootstrap.js here: https://github.com/flutter/flutter/blob/dff09558d3fa6fa22253708df5072fbed9c656c9/packages/flutter_tools/lib/src/web/bootstrap.dart#L154

But when the file gets served by the web server, I see more content appended to the file. That extra content is exactly the same as this var baseUrl = ... in build_web_compilers. I also see code from here being appended.

I don't see a direct dependency on build_web_compilers here. Is it possible that this dependency is being pulled transitively? Or DDC uses it internally?

Note: This only happens in debug mode (using DDC).

cc @jonahwilliams who may have some extra context.

mdebbar avatar Feb 15 '23 18:02 mdebbar

We don't use build_web_compilers, but some of the flutter tool code was taken from bwc initially

jonahwilliams avatar Feb 15 '23 18:02 jonahwilliams

Ok, so probably the fix needs to be in the flutter tool code which was originally taken from bwc. I am not really sure what the right fix is here, or if that logic is even relevant for flutter web.

jakemac53 avatar Feb 15 '23 18:02 jakemac53

I don't think I am going to bother fixing it in bwc unless somebody files an issue as I think this is probably pretty uncommon.

jakemac53 avatar Feb 15 '23 18:02 jakemac53

Thanks @jakemac53 and @jonahwilliams. I transferred the issue to the webdev repo (where dwds lives).

mdebbar avatar Feb 15 '23 18:02 mdebbar

@mdebbar thanks for filing the issue! I'll take a look.

annagrin avatar Feb 23 '23 19:02 annagrin

Can confirm this is still happening with:

  • flutter: v3.2.4
  • js: v0.6.7
  • web: v0.4.2
  • web_socket_channels: v2.4.3

lrsvmb avatar Feb 28 '24 17:02 lrsvmb