You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助排查MaxListenersExceedWarning:EventEmitter内存泄漏问题

求助:解决MaxListenersExceedWarning内存泄漏警告

我碰到了MaxListenersExceedWarning: Possible EventEmitter memory leak detected警告,查过相关问题还是没解决。

我猜测问题可能来自两个地方:

  • CreateThread组件里input的onChange处理逻辑有问题
  • Header中的ConnectButton——控制台提示存在'accountChanged Listeners'相关问题,但我没写过异常逻辑(已附截图)

下面是相关代码,麻烦帮忙分析解决,谢谢!

CreateThread.js组件

import { abi, contractAddresses } from "../constants";
import { useMoralis } from "react-moralis";
import { useEffect, useState } from "react";

export default function startThread() {
  const { chainId: chainIdHex, isWeb3Enabled } = useMoralis();
  const chainId = parseInt(chainIdHex);
  const threadAddress =
    chainIdHex in contractAddresses ? contractAddresses[chainId][0] : null;
  const [threadtitle, setthreadtitle] = useState("");
  const [threadpost, setthreadpost] = useState("");

  const { runContractFunction: createThread } = useWeb3Contract({
    abi: abi,
    contractAddress: threadAddress, 
    functionName: "createThread",
    params: { _threadTitle: threadtitle, _threadPost: threadpost }, //these parameters should come from the input boxes (document.getElementById("threadtitle").value, etc.)
    msgValue: {},
  });

  async function Update() {
    const response = await createThread();
    console.log(response);
  }


 useEffect(() => {
    if (isWeb3Enabled) {
    }
  }, []);

  return (
    <div>
      <div className="bg-slate-400 w-screen h-96 py-4 px-2">
        <div>Threadtitle</div>
        <input
          className=" w-11/12"
          id="threadtitle"
          onChange={(e) => setthreadtitle(e.target.value)}
        ></input>
        <div>Threadpost</div>
        <input
          className=" w-11/12 h-24"
          id="threadpost"
          onChange={(e) => setthreadpost(e.target.value)}
        ></input>
        <div className="py-4">
          <button
            className="bg-blue-500 hover:bg-blue-400 text-white font-bold py-2 px-4 border-b-4 border-blue-700 hover:border-blue-500 rounded"
            onClick={Update}
          >
            Create Thread
          </button>
        </div>
      </div>
    </div>
  );
}

Header.js组件

import { ConnectButton } from "web3uikit";

export default function Header() {
  return (
    <div className="p-5 border-b-2 flex flex-row bg-slate-400">
      <h1 className="py-4 px-4 font-blog text-3xl">
        deAgora - Forum for the people, by the people
      </h1>
      <div className="ml-auto py-2 px-4">
        <ConnectButton moralisAuth={false}></ConnectButton>
      </div>
    </div>
  );
}

内容的提问来源于stack exchange,提问作者Patrick H

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 23:54:28