【问题标题】:"A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received", What does that mean?“监听器通过返回 true 表示异步响应,但消息通道在收到响应之前关闭”,这是什么意思?
【发布时间】:2022-06-26 11:46:01
【问题描述】:

我正在开发一个 React 应用程序,我使用了一些 npm 模块,其中一个是我必须自己构建的。 (我的 NPM 包: https://www.npmjs.com/package/modale-react-rm)。

这是一个简单的模式,用useState() 打开和关闭。

导入我的包后,我的控制台出现一个错误,几秒钟后突然出现但没有执行任何操作。


Uncaught (in promise)                                                                  localhost/:1

    >{message: 'A listener indicated an asynchronous response by r…age channel closed before a response was received'}
         message: "A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received"
        >[[Prototype]]: Object
             >constructor: ƒ ()
             >[[Prototype]]: Object

       /* sometimes there are specific elements in addition but I could not check when they appear and when not */

            Promise.then (asynchrone)       
            (anonyme)              @content_script_bundle.js:108
            handleNewFeatures      @content_script_bundle.js:101
            handleUpdatedNodes     @content_script_bundle.js:101
            (anonyme)              @content_script_bundle.js:101
            childlist(asynchrone)
            0                      @purplebox.js:1
            (anonyme)              @purplebox.js:1
            v                      @purplebox.js:1

它不会阻止我的页面,也不会阻止其功能的正常运行,但这是一个错误,我认为应该修复它,也许可以帮助遇到同样问题的其他人。

我指定我不在此项目中发出任何异步请求。一切都是本地的,我使用的少数数据直接以原始形式导入。 我也不知道 Purplebox.js 是从哪里来的。

【问题讨论】:

    标签: javascript reactjs npm


    【解决方案1】:

    此问题是跨域请求问题,由各种 Chrome 扩展程序引起。 我的 Angular 应用程序中也有这个问题,在隐身模式下对其进行测试后,该错误不再出现。

    更多信息:Google Forum

    【讨论】:

    • 谢谢!实际上,在通过私人浏览时,该消息不再存在。但是我还是不明白为什么会突然发生……
    • 这很难说,我不知道你用的是什么扩展。示例:对我来说它是 Ghostery,它们会产生许多控制台错误。即使在他们自己的网站上,我也会收到这些错误。
    • 对我来说也是一个扩展。我一直在查看我的应用程序,试图找出我在哪里搞砸了它的扩展(Ghostery)。
    • 你是对的!我要删除这个该死的扩展名(Ghostery)。谢谢!!
    • 您可以在 Ghostery 中将站点添加到白名单
    猜你喜欢
    • 2022-09-27
    • 1970-01-01
    • 2019-07-11
    • 2017-08-26
    • 2018-03-26
    • 2019-05-23
    • 2019-08-09
    • 1970-01-01
    • 2020-11-29
    相关资源
    最近更新 更多