Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Error] Apollo-client: Error: ENOENT: no such file or directory, open '/var/folders/d9/295jkct11cb5mpttx9qf26zr0000gp/T/fde-nodeApolloCachedConfig.json' #5

Open
ihaichao opened this issue Apr 30, 2020 · 3 comments

Comments

@ihaichao
Copy link

ihaichao commented Apr 30, 2020

[Error] Apollo-client: Error: ENOENT: no such file or directory, open '/var/folders/d9/295jkct11cb5mpttx9qf26zr0000gp/T/fde-nodeApolloCachedConfig.json'
[Error] Apollo-client: load configs from config files failed

[Info] Apollo-client: start fetching from apollo DB...
[Error] Apollo-client: mismatch fetching configs default-application
[Error] Apollo-client: Error: mismatch fetching configs default-application
[Error] Apollo-client: error on notificaiotn response: , TypeError: body.forEach is not a function

@ihaichao ihaichao changed the title Apollo-client: mismatch fetching configs default-application [Error] Apollo-client: Error: ENOENT: no such file or directory, open '/var/folders/d9/295jkct11cb5mpttx9qf26zr0000gp/T/fde-nodeApolloCachedConfig.json' Apr 30, 2020
@XIRALIP
Copy link

XIRALIP commented May 6, 2020

一样的问题。
代码如下

const Apollo = require('node-apollo-client')
let apollo = new Apollo({
configServerUrl: 'http://172.20.0.75:8070/',
appId: '80001005',
cluster: 'default', // [optional] default to default
namespaces: ['application'], // default to ['application'], this is the namespaces that you want to use or maintain.
initialConfigs: {
VUE_APP_BASE:"444"
}, // [optional]
listenOnNotification: true, // [optional] default to true
fetchCacheInterval: 30e3, // [optional] default to 5 minutes. can be customize but 30s or shorter time are not acceptable.
cachedConfigFilePath: 'C:/data' // [optional] cached configs path, default to system's tmp directory, for linux it's basically '/tmp'.
});
module.exports.initConfig =async function initConfig() {
await apollo.fetchConfig({ key: 'VUE_APP_BASE_API' }).then(msg=>{
console.log('VUE_APP_BASE_API:',msg);
return msg;
});
return apollo;
}
module.exports.getConfig = async function getConfig(key){
return await apollo.fetchConfig({ key: key }).then(msg=>{
console.log('VUE_APP_BASE_API:',msg);
return msg;
});
}

报错信息
[Error] Apollo-client: Error: ENOENT: no such file or directory, open 'C:\data\80001005-nodeApolloCachedConfig.json'
[Error] Apollo-client: load configs from config files failed
DIRECTORY NAME: C:\workspace\iot\iot-developer-web
App running on port 3303
[Info] Apollo-client: start fetching from apollo DB...
[Info] Apollo-client: start fetching from apollo DB...
[Error] Apollo-client: mismatch fetching configs default-application
[Error] Apollo-client: Error: mismatch fetching configs default-application
[Error] Apollo-client: mismatch fetching configs default-VUE_APP_BASE
VUE_APP_BASE:
[Error] Apollo-client: error on notificaiotn response: , TypeError: body.forEach is not a function
[Error] Apollo-client: error on notificaiotn response: , TypeError: body.forEach is not a function
[Error] Apollo-client: error on notificaiotn response: , TypeError: body.forEach is not a function
[Error] Apollo-client: error on notificaiotn response: , TypeError: body.forEach is not a function
[Error] Apollo-client: error on notificaiotn response: , TypeError: body.forEach is not a function
到目前卡在这里了,Apollo也是本地安装的80001005也已经发布了。还是报错如何解决呢?

@shinux
Copy link
Owner

shinux commented Jun 10, 2020

不好意思才看到这个 issue ... GitHub 的通知似乎失效了,不知道各位是不是已经解决或者换 package了,感觉已经迟了。

但是如果问题依然存在,可以按照下述的方法验证一下:

  1. 确认 cachedConfigFilePath 确实存在
  2. node 启动的用户以正常访问 cachedConfigFilePath 路径,不存在权限的问题
  3. 另外配置文件 path 的定位是通过 node.js 自带的 path.join 这个 function 实现的,按照文档所说

The path.join() method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.

参数 array 中每一个被 join 的元素以及分隔符最后都会 normalize,我在 windows 下又重新测试了一下,应该是 work 的
31591780103_ pic_hd

@XIRALIP 我观察到报错的信息的路径和你配置的文件路径的分隔符是不一致的,虽然最后读取的都会是 windows 版本。

另外这个 package 我的同事在 mac OS 的本地和 Ubuntu 作为线上环境已经运行了大概半年的时间.....

有任何不对或者不好理解的地方,请直接告诉我🙏

@shinux
Copy link
Owner

shinux commented Jun 10, 2020

btw 第一次没有找到 local file config 的时候会 log 一次 error,后面任何从 Apollo 缓存和数据库读取到配置后,就不会再有对应的问题了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants