-
Notifications
You must be signed in to change notification settings - Fork 1
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
FetchError: ETIMEDOUT #45
Labels
help
Extra attention is needed
type: bug
Something isn't working.
work: complex
The situation is complex, emergent practices used.
Comments
YDX-2147483647
added
the
work: complex
The situation is complex, emergent practices used.
label
Oct 9, 2023
现在 cfc10ad 采用鸵鸟策略。 反正每次超时的来源随机,而每天会获取多次,一天下来有不小的概率完全获取到。 |
YDX-2147483647
added a commit
that referenced
this issue
Oct 9, 2023
- `fetch_all_sources`时,不再一下子发起所有请求,而一点一点发起,限制并发数量上限。 - 配置文件新增`fetch_concurrency: number`。 Resolves #45
This comment was marked as outdated.
This comment was marked as outdated.
又开始超时了。
|
Merged
如果网络环境不好(如连接流量很小的路由器),同时发出单纯大量请求就会卡住,且不抛出超时错误。 import ky, { TimeoutError } from 'ky'
const raw_urls: string[] = JSON.parse(
await Deno.readTextFile('config/sources_by_selectors.json'),
).sources.map(({ url }: { url: string }) => url)
const urls: string[] = []
for (let m = 0; m < 10; m++) {
urls.push(...raw_urls)
}
function Timer() {
const start = Date.now()
return (): number => {
return (Date.now() - start) / 1e3
}
}
for (let round = 0; round < 5; round++) {
let count = 1
const t = Timer()
await Promise.all(
urls.map(async (u) => {
try {
const text = await ky(u).text()
console.log(
`%c${count} ${t().toFixed(3)}s`,
'color: green',
u,
text.length,
)
} catch (error) {
if (error instanceof TimeoutError) {
console.warn(
`%c${count} Timeout ${t().toFixed(3)}s`,
'color: purple',
)
console.log(u)
} else {
console.error(
`%c${count} Error ${t().toFixed(3)}s`,
'color: red',
)
console.log(u)
console.error(error)
}
}
count += 1
}),
)
console.log('\n\n\n')
}
(本来能到 490,但卡住了) 如果 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
help
Extra attention is needed
type: bug
Something isn't working.
work: complex
The situation is complex, emergent practices used.
从 2023-10-02 10时(UTC+8)开始,持续访问超时,出问题的通知来源不定。至今(2023-10-09)仍未解决。
在校外本地运行常常也如此,获取十几个通知来源后就超时。在校内本地运行正常。
可能的解决方案
Promise.all()
改为串行,或者 sindresorhus/p-all: Run promise-returning & async functions concurrently with optional limited concurrency 。The text was updated successfully, but these errors were encountered: