Flutter Web:在 Flutter 运行时在注入的 client.js 脚本中检测到未处理的错误

Posted

技术标签:

【中文标题】Flutter Web:在 Flutter 运行时在注入的 client.js 脚本中检测到未处理的错误【英文标题】:Flutter Web: Unhandled error detected in the injected client.js script on flutter run 【发布时间】:2021-01-31 05:36:10 【问题描述】:

运行flutter run -d chrome 时出现以下错误。我无法弄清楚这个错误来自哪里。我尝试了here 中的解决方案,但没有改变任何东西。

医生总结(要查看所有详细信息,请运行 flutter doctor -v):[✓] Flutter(通道未知,1.20.2,在 Linux 上,语言环境 en_CA.UTF-8)[✓] android 工具链 - 为 Android 设备开发(Android SDK 版本 30.0.0) [✓] Chrome - 为网络开发 [✓] Android Studio(4.0 版)[✓] 连接设备(4 个可用)

你能帮忙吗?

client.js:3316 Unhandled error detected in the injected client.js script.

You can disable this script in webdev by passing --no-injected-client if it
is preventing your app from loading, but note that this will also prevent
all debugging and hot reload/restart functionality from working.

The original error is below, please file an issue at
https://github.com/dart-lang/webdev/issues/new and attach this output:

NoSuchMethodError: method not found: 'get$digestsPath' (J.getInterceptor$x(...).get$digestsPath is not a function)
TypeError: J.getInterceptor$x(...).get$digestsPath is not a function
    at Object.get$digestsPath$x (http://localhost:35691/dwds/src/injected/client.js:3529:43)
    at http://localhost:35691/dwds/src/injected/client.js:22757:60
    at _wrapJsFunctionForAsync_closure.$protected (http://localhost:35691/dwds/src/injected/client.js:3824:15)
    at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:35691/dwds/src/injected/client.js:11021:12)
    at Object._asyncStartSync (http://localhost:35691/dwds/src/injected/client.js:3788:20)
    at RequireRestarter._getDigests$0 (http://localhost:35691/dwds/src/injected/client.js:22769:16)
    at http://localhost:35691/dwds/src/injected/client.js:22784:48
    at _wrapJsFunctionForAsync_closure.$protected (http://localhost:35691/dwds/src/injected/client.js:3824:15)
    at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:35691/dwds/src/injected/client.js:11021:12)
    at Object._asyncStartSync (http://localhost:35691/dwds/src/injected/client.js:3788:20)
    at RequireRestarter._initialize$0 (http://localhost:35691/dwds/src/injected/client.js:22792:16)
    at http://localhost:35691/dwds/src/injected/client.js:8594:45
    at _wrapJsFunctionForAsync_closure.$protected (http://localhost:35691/dwds/src/injected/client.js:3824:15)
    at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:35691/dwds/src/injected/client.js:11021:12)
    at Object._asyncStartSync (http://localhost:35691/dwds/src/injected/client.js:3788:20)
    at Object.RequireRestarter_create (http://localhost:35691/dwds/src/injected/client.js:8606:16)
    at http://localhost:35691/dwds/src/injected/client.js:22344:38
    at _wrapJsFunctionForAsync_closure.$protected (http://localhost:35691/dwds/src/injected/client.js:3824:15)
    at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:35691/dwds/src/injected/client.js:11021:12)
    at _awaitOnObject_closure.call$1 (http://localhost:35691/dwds/src/injected/client.js:11007:32)
    at StaticClosure._rootRunUnary [as call$2$5] (http://localhost:35691/dwds/src/injected/client.js:4152:18)
    at _CustomZone.runUnary$2$2 (http://localhost:35691/dwds/src/injected/client.js:12326:39)
    at _Future__propagateToListeners_handleValueCallback.call$0 (http://localhost:35691/dwds/src/injected/client.js:11387:51)
    at Object._Future__propagateToListeners (http://localhost:35691/dwds/src/injected/client.js:3936:93)
    at _Future._complete$1 (http://localhost:35691/dwds/src/injected/client.js:11211:11)
    at Object._cancelAndValue (http://localhost:35691/dwds/src/injected/client.js:4091:16)
    at Stream_first_closure0.call$1 (http://localhost:35691/dwds/src/injected/client.js:11479:9)
    at _EventStreamSubscription_onData_closure.call$1 (http://localhost:35691/dwds/src/injected/client.js:17334:30)
    at StaticClosure._rootRunUnary [as call$2$5] (http://localhost:35691/dwds/src/injected/client.js:4158:16)
    at _CustomZone.runUnary$2$2 (http://localhost:35691/dwds/src/injected/client.js:12326:39)
    at _CustomZone.runUnaryGuarded$1$2 (http://localhost:35691/dwds/src/injected/client.js:12258:14)
    at _CustomZone_bindUnaryCallbackGuarded_closure.call$1 (http://localhost:35691/dwds/src/injected/client.js:12461:25)
    at invokeClosure (http://localhost:35691/dwds/src/injected/client.js:1205:26)
    at EventSource.<anonymous> (http://localhost:35691/dwds/src/injected/client.js:1224:18)

【问题讨论】:

【参考方案1】:

Chrome 的更改似乎导致了已通过更改 Dart SDK 解决的问题。

flutter upgrade 将为您提供可以解决此错误的最新 Dark SDK。

More information 在 Github 上的 SDK update

【讨论】:

我遇到了同样的问题,升级颤振后错误消失了。我遇到错误时的 Flutter 版本(Channel beta,1.19.0-4.3.pre,在 Microsoft Windows 上)我当前的版本是 Channel beta,1.23.0-18.1.pre,在 Microsoft Windows 上。

以上是关于Flutter Web:在 Flutter 运行时在注入的 client.js 脚本中检测到未处理的错误的主要内容,如果未能解决你的问题,请参考以下文章

Flutter:在浏览器中运行网页版时如何停止显示移动应用

尝试使用 Firebase 远程配置运行 Flutter WEB 应用程序时出错 [关闭]

Flutter Web - 外部编辑时文件不更新

在 WEB 中运行 Flutter:错误:XMLHttpRequest 错误

在 Flutter Web (Vs Code) 中运行任何东西时控制台中的错误

通过 VSCode 运行 Flutter 项目时找不到名为“web-server-debug-protocol”的选项