-
Notifications
You must be signed in to change notification settings - Fork 45
Fix: return an error on body read timeout when the response has no Content-Length #137
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
Fix: return an error on body read timeout when the response has no Content-Length #137
Conversation
.github/workflows/linux.yml
Outdated
| matrix: | ||
| perl-version: | ||
| - '5.14' | ||
| - '5.26' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perl:5.14 のimage では以下の問題が発生。
2025-09-23T14:12:53.8469117Z ##[command]/usr/bin/docker pull perl:5.14
2025-09-23T14:12:54.0843447Z 5.14: Pulling from library/perl
2025-09-23T14:12:54.0850220Z [DEPRECATION NOTICE] Docker Image Format v1 and Docker Image manifest version 2, schema 1 support is disabled by default and will be removed in an upcoming release. Suggest the author of docker.io/library/perl:5.14 to upgrade the image to the OCI Format or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/
2025-09-23T14:12:54.0960876Z ##[error]Docker pull failed with exit code 1
https://github.com/yuji-hatakeyama/Furl/actions/runs/17948982318/job/51042726049#step:2:29
Perl 5.22 の image でこの問題は解消したが、別の問題が発生。
2025-09-23T19:51:01.0459218Z ##[command]/usr/bin/docker exec d2f4656322d911b45a166eeaf01e473b0bf185e85cf15ea4595c869897b3851b sh -c "cat /etc/*release | grep ^ID"
2025-09-23T19:51:01.1598277Z /__e/node20/bin/node: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found (required by /__e/node20/bin/node)
2025-09-23T19:51:01.1601034Z /__e/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /__e/node20/bin/node)
2025-09-23T19:51:01.1601897Z /__e/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by /__e/node20/bin/node)
https://github.com/yuji-hatakeyama/Furl/actions/runs/17957388349/job/51072107739
5.26 で解消することが確認できたたため '5.14' => '5.26' に変更しました。
https://github.com/yuji-hatakeyama/Furl/actions/runs/17957825083/job/51073646548
比較的新しいDebian などのイメージ (buster 以降なら問題ないと思われる) に、自分で perl 5.14 をインストールするように変更すれば解消する可能があると思います。
調査および対応したほうが望ましければ、別で行いたいと考えていますのでご連絡ください。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こちら -buster を versionの後ろに付ければ解消されるはずなのでそちらを試していただけないでしょうか ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@syohex san
ご確認ありがとうございます。 Buster の build 済みの image が存在したんですね 😅
使用したところ正常のテストが実施できました。
https://github.com/yuji-hatakeyama/Furl/actions/runs/17966814895/job/51100904420
3f8bce9 で修正しました。
Changelog diff is: diff --git a/Changes b/Changes index 81a6724..aa0adb1 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,10 @@ Revision history for Perl module Furl {{$NEXT}} +3.15 2025-09-25T00:24:03Z + - Fix the issue that when timeout happens, then request method returns success when + there is no Content-Length headers(#137) + 3.14 2021-05-13T05:30:22Z - Support 308 HTTP status code
|
Thanks. I've release new version https://metacpan.org/release/SYOHEX/Furl-3.15 |
|
Thank you for the quick review and release! I really appreciate your prompt response. |
(日本語で失礼します。英語で作成したほうが良ければご連絡ください)
概要
通常、HTTP レスポンスボディの受信中にクライアント側でタイムアウトした場合は、
Cannot read content body: timeout ...というエラーを返す挙動になっています。Furl/lib/Furl/HTTP.pm
Line 842 in 9866ebf
しかし、レスポンスヘッダに
Content-Lengthがない場合に限って、タイムアウト時でもその時点まで受信できたボディを正常扱いで返してしまう挙動がありました
(結果としてボディが途中で切れてしまう)。
Furl/lib/Furl/HTTP.pm
Line 839 in 9866ebf
この挙動を修正し、
Content-Lengthがない場合でもボディ受信中のタイムアウトはエラーを返すようにしました。経緯
あるスクリプトで JSON を返す API に対して以下のようなリクエストを実行していましたが、
まれに JSON のデコードに失敗しました(
$res->is_successを確認後にもかかわらず)。失敗時はスクリプトの実行時間がタイムアウト値と同程度になっていることが多く(通常は 2〜3秒)、
タイムアウトを 60 秒から 1 秒へ下げると高確率で再現しました。
このことから、「クライアント側でのタイムアウトが発生したときに
$res->is_successになるが、レスポンスが途中で切れてしまう」というパターンがあることに気付きました。一次対応として JSON デコード失敗時にリトライしていますが、本修正により根本的に解消されます。
方針・実装内容のご確認をお願いいたします。