webdev icon indicating copy to clipboard operation
webdev copied to clipboard

Invalid format exception on `webdev serve`

Open themisir opened this issue 3 years ago • 6 comments

I was trying out dart webdev tool with dart create "web-simple" template. I created a new project using dart create . -t web-simple then used webdev serve to start development server.

When I tried to access preview url I got this error on console:

FormatException: Scheme not starting with alphabetic character (at character 1)
@http://127.0.0.1:8080/main.dart.bootstrap.js
^
The whole terminal output
❯ webdev serve
[INFO] Reading cached asset graph completed, took 206ms
[INFO] Checking for updates since last build completed, took 501ms
[INFO] Serving `web` on http://127.0.0.1:8080
[INFO] Running build completed, took 124ms
[INFO] Caching finalized dependency graph completed, took 165ms
[INFO] Succeeded after 296ms with 0 outputs (0 actions)
[INFO] --------------------------------------------------------------------------------------------
ERROR - 2022-02-11 16:52:03.661574
GET /@http://127.0.0.1:8080/main.dart.bootstrap.js
Error thrown by handler.
FormatException: Scheme not starting with alphabetic character (at character 1)
@http://127.0.0.1:8080/main.dart.bootstrap.js
^

dart:core                                          _SimpleUri.resolve
package:shelf_proxy/shelf_proxy.dart 42:28         proxyHandler.<fn>
package:shelf_proxy/shelf_proxy.dart 37:10         proxyHandler.<fn>
package:shelf/src/cascade.dart 77:53               Cascade.handler.<fn>.<fn>
===== asynchronous gap ===========================
package:shelf/shelf_io.dart 74:34                  serveRequests.<fn>.<fn>
===== asynchronous gap ===========================
package:shelf/shelf_io.dart 73:3                   serveRequests
package:webdev/src/util.dart 24:5                  serveHttpRequests.<fn>
package:stack_trace                                Chain.capture
package:webdev/src/util.dart 23:16                 serveHttpRequests
package:webdev/src/serve/webdev_server.dart 185:5  WebDevServer.start

ERROR - 2022-02-11 16:52:19.133559
GET /@http://127.0.0.1:8080/main.dart.bootstrap.js
Error thrown by handler.
FormatException: Scheme not starting with alphabetic character (at character 1)
@http://127.0.0.1:8080/main.dart.bootstrap.js
^

dart:core                                          _SimpleUri.resolve
package:shelf_proxy/shelf_proxy.dart 42:28         proxyHandler.<fn>
package:shelf_proxy/shelf_proxy.dart 37:10         proxyHandler.<fn>
package:shelf/src/cascade.dart 77:53               Cascade.handler.<fn>.<fn>
===== asynchronous gap ===========================
package:shelf/shelf_io.dart 74:34                  serveRequests.<fn>.<fn>
===== asynchronous gap ===========================
package:shelf/shelf_io.dart 73:3                   serveRequests
package:webdev/src/util.dart 24:5                  serveHttpRequests.<fn>
package:stack_trace                                Chain.capture
package:webdev/src/util.dart 23:16                 serveHttpRequests
package:webdev/src/serve/webdev_server.dart 185:5  WebDevServer.start

If you don't have bandwidth to handle this issue, I would be happy to look into it, I would just need some pointers to know where to start.

themisir avatar Feb 11 '22 13:02 themisir

@themisir Are you using Safari? If you use another browser, you won't get an error.

I tried

  • ⭕ Chromium 98.0.4758.102 snap, Mozilla Firefox 97.0 [Ubuntu 21.10 aarch64]
  • ⭕ Chromium Version 101.0.4918.0 (Developer Build) (x86_64) Firefox 97.0.2 (64-bit) [macOS Monterey Version 12.3 Beta (21E5227a) (Intel)]
  • ❌ Safari Version 15.4 (17613.1.17.1.6) [macOS Monterey Version 12.3 Beta (21E5227a) (Intel)]
  • ❌ iPadOS 15.3.1 (Safari etc...)

Mogyuchi avatar Mar 07 '22 08:03 Mogyuchi

Still happens here. I'm on M1 macOS Monterey 12.3.1, Safari 15.4, Dart 2.18.6, and webdev 2.7.11. When creating a project using dart create -t web, the same format exception is thrown only on Safari:

[INFO] Building new asset graph completed, took 2.0s
[INFO] Checking for unexpected pre-existing outputs. completed, took 0ms
[INFO] Serving `web` on http://127.0.0.1:8080
[INFO] Generating SDK summary completed, took 2.2s
[INFO] Running build completed, took 32.1s
[INFO] Caching finalized dependency graph completed, took 515ms
[INFO] Succeeded after 32.6s with 7160 outputs (14546 actions)
[INFO] --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ERROR - 2023-01-14 20:56:12.497063
GET /@http://localhost:8080/main.dart.bootstrap.js
Error thrown by handler.
FormatException: Scheme not starting with alphabetic character (at character 1)
@http://localhost:8080/main.dart.bootstrap.js
^

dart:core                                          _Uri.resolve
package:shelf_proxy/shelf_proxy.dart 42:28         proxyHandler.<fn>
package:shelf/src/cascade.dart 77:53               Cascade.handler.<fn>.<fn>
===== asynchronous gap ===========================
package:shelf/shelf_io.dart 91:9                   serveRequests.<fn>.<fn>
===== asynchronous gap ===========================
package:shelf/shelf_io.dart 89:3                   serveRequests
package:webdev/src/util.dart 24:5                  serveHttpRequests.<fn>
package:stack_trace                                Chain.capture
package:webdev/src/util.dart 23:16                 serveHttpRequests
package:webdev/src/serve/webdev_server.dart 184:5  WebDevServer.start

GZGavinZhao avatar Jan 15 '23 02:01 GZGavinZhao

Adding on to it, this seems like a problem by dartdevc instead of webdev, because if I use webdev serve --release to force webdev to use dart2js, the problem goes away.

Additionally, if I do webdev build --no-release to force using dartdevc and then serve the files directly (e.g. dhttpd --path=build), the same error occurs:

> dhttpd --path=build
Server started on port 8080
2023-01-14T21:07:00.956095  0:00:00.007707 GET     [200] /
2023-01-14T21:07:00.977470  0:00:00.000474 GET     [200] /styles.css
2023-01-14T21:07:00.979183  0:00:00.000238 GET     [200] /main.dart.js
2023-01-14T21:07:00.984345  0:00:00.000344 GET     [200] /packages/build_web_compilers/src/dev_compiler/require.js
2023-01-14T21:07:00.985562  0:00:00.000261 GET     [200] /packages/build_web_compilers/src/dev_compiler_stack_trace/stack_trace_mapper.dart.js
2023-01-14T21:07:00.998798  0:00:00.000924 GET     [404] /@http://localhost:8080/main.dart.bootstrap.js
2023-01-14T21:07:01.426363  0:00:00.010799 GET     [304] /
2023-01-14T21:07:01.441603  0:00:00.000494 GET     [304] /styles.css
2023-01-14T21:07:01.442997  0:00:00.000385 GET     [304] /main.dart.js
2023-01-14T21:07:01.446858  0:00:00.000539 GET     [304] /packages/build_web_compilers/src/dev_compiler_stack_trace/stack_trace_mapper.dart.js
2023-01-14T21:07:01.448434  0:00:00.000446 GET     [304] /packages/build_web_compilers/src/dev_compiler/require.js
2023-01-14T21:07:01.459252  0:00:00.000180 GET     [404] /@http://localhost:8080/main.dart.bootstrap.js
2023-01-14T21:07:02.369460  0:00:00.000511 GET     [304] /
2023-01-14T21:07:02.373869  0:00:00.000524 GET     [304] /styles.css
2023-01-14T21:07:02.375522  0:00:00.000451 GET     [304] /main.dart.js
2023-01-14T21:07:02.378332  0:00:00.000585 GET     [304] /packages/build_web_compilers/src/dev_compiler/require.js
2023-01-14T21:07:02.380013  0:00:00.000452 GET     [304] /packages/build_web_compilers/src/dev_compiler_stack_trace/stack_trace_mapper.dart.js
2023-01-14T21:07:02.389053  0:00:00.000167 GET     [404] /@http://localhost:8080/main.dart.bootstrap.js

GZGavinZhao avatar Jan 15 '23 02:01 GZGavinZhao

@jyameo can you verify if this is still an issue or not?

bkonyi avatar Dec 04 '24 19:12 bkonyi

I can confirm that the issue still exists with

webdev --version                             
3.7.1
GET /@http://127.0.0.1:8080/main.dart.bootstrap.js
Error thrown by handler.
FormatException: Scheme not starting with alphabetic character (at character 1)
@http://127.0.0.1:8080/main.dart.bootstrap.js
^

For me the problem is that I'm using a flutter in app webview on macos so I'm stuck with developing against safari

dkbast avatar Mar 20 '25 15:03 dkbast

FYI @natebiggs. It sounds like this might be a DDC issue.

bkonyi avatar Mar 20 '25 15:03 bkonyi