React Native升级后Chrome调试卡在Loading from Metro问题排查
问题:React Native 0.69.4 Chrome调试卡在「Loading from Metro...」
- 手动将React Native版本从0.66.3升级到0.69.4(
npx react-native upgrade工具无法正常更新文件),项目可正常运行,但点击设备调试工具的「Debug with Chrome」按钮后,应用卡在「Loading from Metro...」状态无进展。 - 控制台重新加载时显示
0/1后立即提示打包完成,但应用仍处于冻结状态,无法唤起调试工具选项。 - 尝试使用Flipper调试,但功能不稳定且日志为无格式纯文本,已卸载。
疑问:
- React Native是否已移除Chrome调试支持?
- 若未移除,该问题可能由哪些文件或代码行导致?
项目package.json配置:
{ "version": "0.0.1", "private": true, "scripts": { "format": "yarn prettier -c '**/*.+(js|json|ts|tsx|md)'", "format:fix": "yarn prettier --write '**/*.+(js|json|ts|tsx|md)'", "typecheck": "tsc --noEmit", "commit": "git-cz", "generateTypes": "graphql-codegen", "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest --runInBand --detectOpenHandles --forceExit", "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "dependencies": { "@apollo/client": "^3.6.9", "apollo-upload-client": "^17.0.0", "date-fns": "^2.29.1", "eventemitter3": "^4.0.7", "graphql": "^16.5.0", "graphql-ws": "^5.10.0", "i18next": "^21.9.0", "react": "18.2.0", "react-i18next": "^11.18.3", "react-native": "0.69.4", "react-native-encrypted-storage": "^4.0.2", "react-native-fast-image": "^8.5.11", "react-native-get-random-values": "^1.8.0", "react-native-image-picker": "^4.8.5", "react-native-keychain": "^8.1.1", "react-native-notification-sounds": "^0.5.4", "react-native-sound": "^0.11.2", "react-native-splash-screen": "^3.3.0", "react-native-svg": "^12.4.4", "react-native-vector-icons": "^9.2.0", "react-redux": "^8.0.2", "react-router-native": "^5.3.3", "redux": "^4.2.0", "redux-thunk": "^2.4.1", "subscriptions-transport-ws": "^0.11.0", "uuid": "^8.3.2", "victory-native": "^36.3.0", "ws": "^8.8.1" }, "devDependencies": { "@babel/core": "^7.18.10", "@babel/preset-typescript": "^7.18.6", "@babel/runtime": "^7.18.9", "@graphql-codegen/add": "3.2.1", "@graphql-codegen/cli": "2.11.6", "@graphql-codegen/import-types-preset": "2.2.3", "@graphql-codegen/typescript": "2.7.3", "@graphql-codegen/typescript-operations": "2.5.3", "@graphql-codegen/typescript-react-apollo": "3.3.3", "@react-native-community/cli": "^8.0.5", "@react-native-community/eslint-config": "^3.1.0", "@testing-library/jest-native": "^4.0.11", "@testing-library/react-native": "^11.0.0", "@types/apollo-upload-client": "^17.0.1", "@types/jest": "^28.1.6", "@types/node": "^18.7.1", "@types/react": "^18.0.17", "@types/react-native": "^0.69.5", "@types/react-native-vector-icons": "^6.4.11", "@types/react-redux": "^7.1.24", "@types/react-router-native": "^5.1.3", "@types/react-test-renderer": "^18.0.0", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^5.33.0", "@typescript-eslint/parser": "^5.33.0", "babel-jest": "^28.1.3", "babel-plugin-transform-inline-environment-variables": "^0.4.4", "commitizen": "^4.2.5", "cz-conventional-changelog": "^3.3.0", "eslint": "^8.21.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-react": "^7.30.1", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-native": "^4.0.0", "flow-bin": "^0.184.0", "husky": "^8.0.1", "jest": "^28.1.3", "lint-staged": ">=13", "metro-react-native-babel-preset": "^0.72.0", "mockdate": "^3.0.5", "react-native-eject": "^0.1.2", "react-test-renderer": "18.2.0", "redux-devtools-extension": "^2.13.9", "ts-jest": "^28.0.7", "typescript": "^4.7.4" }, "resolutions": { "@types/react": "^17" }, "husky": { "hooks": { "pre-commit": "lint-staged", "prepare-commit-msg": "exec < /dev/tty && git cz --hook || true" } }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } } }
更新:最终确认是网络问题——iPad通过WiFi运行应用无异常,但开启Chrome调试就出现卡顿。iPhone上出现报错:
Connection to http://localhost:8081/debugger-proxy?role=client timed out,排查后确认是网络问题。
内容的提问来源于stack exchange,提问作者Gergő Horváth
相关产品推荐
相关产品推荐

