timeout isn't working
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- nodejs, typescript
調査の方向性
request-light の xhr エントリポイントから開始し、timeout オプションが Node.js リクエストにどのように適用されるかを追跡します。Issue にある動作する https の例と挙動を比較します。完了条件は、timeout: 1000 を指定したリクエストが完全なレスポンスを待つのではなく、reject または abort されることです。
索引モデルが issue の本文から書いたものです。
説明
AFAIK calling request.setTimeout(ms) does not automatically abort or fail the request when the timeout is reached. Instead, it simply emits a 'timeout' event on the request object where we would need to abort the request manually.
There isn't any logic in node-request-light capturing the timeout event so it will never timeout..
Recreation script (where 'request-light' is present in the node_modules folder):
const { xhr } = require('request-light');
async function testTimeout() {
const timeoutMs = 1000;
// This URL will wait for 10 seconds before responding
const url = 'https://httpbin.org/delay/10';
console.log(`Starting request to ${url} with a ${timeoutMs}ms timeout...`);
const start = Date.now();
try {
const response = await xhr({
url,
timeout: timeoutMs
});
console.log(`Request finished successfully after ${Date.now() - start}ms (Status: ${response.status})`);
} catch (error) {
const duration = Date.now() - start;
console.log(`Request failed after ${duration}ms`);
if (error.status === 408 || error.message?.includes('timeout') || duration < 2000) {
console.log('SUCCESS: The timeout was respected.');
} else {
console.log('FAILURE: The timeout was NOT respected. It likely waited for the full response.');
}
console.log('Error details:', error);
}
}
testTimeout();
working nodejs example
const https = require('https');
function testWorkingTimeout() {
const timeoutMs = 1000;
const url = 'https://httpbin.org/delay/10';
console.log(`Starting Node.js native request to ${url} with a ${timeoutMs}ms timeout...`);
const start = Date.now();
const req = https.get(url, (res) => {
console.log('This should not be reached if timeout works.');
});
// Set the timeout
req.setTimeout(timeoutMs);
// Listen for the 'timeout' event (This is what request-light is missing)
req.on('timeout', () => {
console.log(`[TIMEOUT EVENT] Triggered after ${Date.now() - start}ms. Manually destroying the request...`);
req.destroy(new Error('ETIMEDOUT'));
});
req.on('error', (err) => {
console.log(`[ERROR EVENT] Request failed as expected: ${err.message}`);
console.log(`Total duration: ${Date.now() - start}ms`);
if (Date.now() - start < 2000) {
console.log('SUCCESS: The timeout was respected because we handled the event.');
}
});
}
testWorkingTimeout();
- 主要言語
- TypeScript
- スター
- 35
- フォーク
- 22
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/node-request-light のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
microsoft/node-request-light#27 · コメント 1 件 ·
-
NO_PROXY supportオープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
microsoft/node-request-light#10 · リアクション 1 件 ·
microsoft/node-request-light の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
betagouv/mon-entreprise#4699 ·
メンテナーはふだん 3 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
jaegertracing/jaeger-ui#4547 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
ai-driven-qa
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
linagora/twake-calendar-frontend#1467 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
need4deed-org/sdk#267 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
auth0/universal-login#414 ·
メンテナーはふだん 1 日以内に返信