monorepo環境でExpoを使っているときに出る Invariant Violation: No callback found with cbID xxxx and callID xxxx for module <unknown>. Args: '[xxxxx]', js engine: hermes を解消する
ERROR Invariant Violation: No callback found with cbID 4781 and callID 2390 for module <unknown>. Args: '[1233]', js engine: hermes
ERROR Invariant Violation: No callback found with cbID 4785 and callID 2392 for module <unknown>. Args: '[1234]', js engine: hermes
ERROR Invariant Violation: No callback found with cbID 4789 and callID 2394 for module <unknown>. Args: '[1235]', js engine: hermes
ERROR Invariant Violation: No callback found with cbID 4793 and callID 2396 for module <unknown>. Args: '[1236]', js engine: hermes
ERROR Invariant Violation: No callback found with cbID 4797 and callID 2398 for module <unknown>. Args: '[1237]', js engine: hermes
ERROR Invariant Violation: No callback found with cbID 4801 and callID 2400 for module <unknown>. Args: '[1238]', js engine: hermes
ERROR Invariant Violation: No callback found with cbID 4805 and callID 2402 for module <unknown>. Args: '[1239]', js engine: hermes
ERROR Invariant Violation: No callback found with cbID 4809 and callID 2404 for module <unknown>. Args: '[1240]', js engine: hermes
ERROR Invariant Violation: No callback found with cbID 4813 and callID 2406 for module <unknown>. Args: '[1241]', js engine: hermes
ERROR Invariant Violation: No callback found with cbID 4817 and callID 2408 for module <unknown>. Args: '[1242]', js engine: hermes
こんなのが無限に出る。
WARN Excessive number of pending callbacks: 501. Some pending callbacks that might have leaked by never being called from native code: {"1":{"module":"AppState","method":"getCurrentAppState"},"11":{},"13":{},"35":{},"37":{},"43":{"module":"Networking","method":"sendRequest"},"45":{},"46":{"module":"Networking","method":"sendRequest"},"48":{},"49":{"module":"Networking","method":"sendRequest"},"51":{},"52":{"module":"Networking","method":"sendRequest"},"54":{},"55":{"module":"Networking","method":"sendRequest"},"57":{},"58":{"module":"Networking","method":"sendRequest"},"60":{"module":"Networking","method":"sendRequest"},"61":{"module":"Networking","method":"sendRequest"},"63":{"module":"Networking","method":"sendRequest"},"64":{"module":"Networking","method":"sendRequest"},"66":{"module":"Networking","method":"sendRequest"},"67":{"module":"Networking","method":"sendRequest"},"69":{"module":"Networking","method":"sendRequest"},"70":{"module":"Networking","method":"sendRequest"},"72":{"module":"Networking","method":"sendRequest"},"73":{"module":"Networking","method":"sendRequest"},"74":{"module":"Networking","method":"sendRequest"},"76":{"module":"Networking","method":"sendRequest"},"77":{"module":"Networking","method":"sendRequest"},"79":{"module":"Networking","method":"sendRequest"},"80":{"module":"Networking","method":"sendRequest"},"82":{"module":"Networking","method":"sendRequest"},"83":{},"85":{},"86":{"module":"Networking","method":"sendRequest"},"88":{"module":"Networking","method":"sendRequest"},"89":{},"91":{},"113":{},"115":{},"117":{},"119":{},"121":{},"123":{},"125":{},"127":{},"129":{},"131":{},"133":{},"135":{},"...(truncated keys)...":451}
あとたまにだけどこんなのも出てるかも。
解決方法
metro.config.jsに以下を追加する。
config.resolver.disableHierarchicalLookup = true
こんな感じ。
// 省略
function withMonorepoPaths(config) {
const projectRoot = __dirname;
const workspaceRoot = path.resolve(projectRoot, "../..");
config.watchFolders = [workspaceRoot];
config.resolver.nodeModulesPaths = [
path.resolve(projectRoot, "node_modules"),
path.resolve(workspaceRoot, "node_modules"),
];
config.resolver.disableHierarchicalLookup = true; // 追加
return config;
}