gpt4 book ai didi

javascript - 错误: ETIMEDOUT on NPM usage in Meteor

转载 作者:行者123 更新时间:2023-12-03 06:56:49 24 4
gpt4 key购买 nike

我尝试使用this Meteor 1.3.2.4 中的 NPM 包。它在函数中使用 eventemitter 并具有异步回调。我尝试使用基于 this guide articleMeteor.bindEnvironment 将其转换为同步外观。如下所示:

Meteor.methods({
proxyFetcher() {
console.log("OK run");
var options = {
protocols: ['http'],
anonymityLevels: ['elite'],
sourcesBlackList: ['bitproxies', 'kingproxies']
};

var gettingProxies = ProxyLists.getProxies(options);
Proxies.remove({});

gettingProxies.on('data', Meteor.bindEnvironment(function(proxies) {
console.log(proxies.length);
proxies.forEach((proxy) => {
Proxies.insert({proxy: proxy.ipAddress + ":" + proxy.port});
});
// Received some proxies.
}));
}
}

但这是我的输出:

I20160515-12:08:02.579(4.5)? OK run
I20160515-12:08:03.250(4.5)? 44
I20160515-12:08:03.645(4.5)? 29
I20160515-12:08:03.963(4.5)? 35
I20160515-12:08:04.376(4.5)? 349
I20160515-12:08:04.711(4.5)? 337
I20160515-12:08:05.071(4.5)? 350
I20160515-12:08:05.853(4.5)? 330
I20160515-12:08:06.149(4.5)? 323
I20160515-12:08:06.443(4.5)? 331
I20160515-12:08:06.737(4.5)? 324
I20160515-12:08:07.039(4.5)? 334
W20160515-12:08:08.083(4.5)? (STDERR)
W20160515-12:08:08.084(4.5)? (STDERR) Error: ETIMEDOUT
W20160515-12:08:08.085(4.5)? (STDERR) at [object Object]._onTimeout (/home/cyc/Programming/Projects/proxyCheck/Sources/node_modules/proxy-lists/node_modules/request/request.js:762:15)
W20160515-12:08:08.085(4.5)? (STDERR) at Timer.listOnTimeout [as ontimeout] (timers.js:121:15)
=> Exited with code: 8
=> Meteor server restarted

正如您所看到的,服务器重新启动并且我的代码在经过一些迭代后返回错误。问题是什么以及将此包与 Meteor 一起使用的正确方法是什么。

最佳答案

大概是 proxy-lists 发出的一个 http 请求失败了,并且这个错误没有被捕获,所以它正在冒泡,导致整个 Node 进程崩溃。

如果您处理了错误,应该可以防止它使进程崩溃:

gettingProxies.on('error', function(error) {
// Some error has occurred.
console.error(error);
});

关于javascript - 错误: ETIMEDOUT on NPM usage in Meteor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37236080/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com