最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - NETWORK_ERROR. under next14 server side it cannot connect to local chain (eg, npx hardhat node), but the same file wor

programmeradmin1浏览0评论

general description of the problem,

  • OK if standalone run: ethers provider object can sucessfully attach with the hardhat local chain (ie, "npx hardhat node") at 127.0.0.1:8545, and do normal operations.
  • NOK inside next14-react project at pure backend (ie, no CORS), executing exactly the same script (ie, not a copy, but the same file).

message of failure,

  • Error: Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)

nature of the failure, after inspecting ethers.provider object (eg, provider.connection will be written as .connection),

  • .connection: correct. url: "http://127.0.0.1:8545", chainId: 31337, name: "hardhat-local"
  • ._network: not appear. instead it appears ._networkPromise, suggesting it's uncapable of connecting to the chain
  • .anyNetwork =false
  • .lastBlockNumber =-2
  • .ready: exists. this suggests again it cannot connect to the chain. but the cause it's a mistery, even to model gpt o1 pro.

context,

  • win 10, next14

  • verbosity =ON when launching the npx hardhat node,

  hardhat:core:vars:varsManager Creating a new instance of VarsManager +0ms
    hardhat:core:vars:varsManager Loading ENV variables if any +1ms
    hardhat:core:config Loading Hardhat config from E:\Masteruviana\data\programacion\mondogit\regis\registerer\src\contracts\hardhat.config.js +0ms
    hardhat:core:hre Creating HardhatRuntimeEnvironment +0ms
    hardhat:core:global-dir Looking up Client Id at C:\Users\pete\AppData\Local\hardhat-nodejs\Data\analytics.json +0ms
    hardhat:core:global-dir Client Id found: a0982142-5f66-47fb-a2bb-7edde32f2183 +3ms
    hardhat:core:hre Running task node +9ms
    hardhat:core:hre Running task node:get-provider +2ms
    hardhat:core:hre Creating provider for network hardhat +0ms
    hardhat:core:hardhat-network:provider Making tracing config +0ms
    hardhat:core:hardhat-network:provider Creating EDR provider +2ms
    hardhat:core:hardhat-network:provider EDR provider created +8ms
    hardhat:core:hre Running task node:create-server +4s
    hardhat:core:hre Running task node:server-created +65ms
    hardhat:core:hardhat-network:jsonrpc Starting JSON-RPC server on port 8545 +0ms
    hardhat:core:compilation-watcher Watching changes on 'E:\Masteruviana\data\programacion\mondogit\regis\registerer\src\contracts\src\contracts\__artifacts\build-info' +0ms
    hardhat:core:hre Running task node:server-ready +95ms
  Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/
  • dependencies of the project,
   "dependencies": {
       "@headlessui/react": "^2.2.0",
       "@nextui-/react": "^2.4.8",
       "@nextui-/select": "^2.2.7",
       "@nextui-/system": "^2.2.6",
       "@nextui-/theme": "^2.2.11",
       "@pinata/sdk": "^2.1.0",
       "@radix-ui/react-label": "^2.1.0",
       "@radix-ui/react-radio-group": "^1.2.1",
       "@radix-ui/react-select": "^2.1.2",
       "@radix-ui/react-slot": "^1.1.0",
       "busboy": "^1.6.0",
       "canvas": "^3.0.1",
       "class-variance-authority": "^0.7.1",
       "clsx": "^2.1.1",
       "form-data": "^4.0.1",
       "formidable": "^3.5.2",
       "framer-motion": "^11.12.0",
       "fs": "^0.0.1-security",
       "jspdf": "^2.5.2",
       "lucide-react": "^0.462.0",
       "mongodb": "^6.10.0",
       "next": "15.0.2",
       "next-themes": "^0.4.3",
       "node-fetch": "^2.7.0",
       "nodemailer": "^6.9.16",
       "pdf-parse": "^1.1.1",
       "pdfjs-dist": "^4.8.69",
       "pinata": "^1.7.2",
       "pinata-web3": "^0.5.2",
       "qrcode": "^1.5.4",
       "react": "^18.2.0",
       "react-dom": "^18.2.0",
       "react-dropzone": "^14.3.2",
       "react-icons": "^5.3.0",
       "tailwind-merge": "^2.5.5",
       "tailwindcss-animate": "^1.0.7",
       "tesseract.js": "^5.1.1",
       "uuid": "^11.0.3"
   },
   "devDependencies": {
       "@nomiclabs/hardhat-ethers": "^2.2.3",
       "@types/react": "18.3.12",
       "chai": "^5.1.2",
       "daisyui": "^4.12.14",
       "dotenv": "^16.4.7",
       "ethers": "^5.7.2",
       "hardhat": "^2.22.17",
       "postcss": "^8",
       "tailwindcss": "^3.4.1",
       "typescript": "5.7.2"
   }

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论