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

pass custom timeout to subsequent requests #615

Merged
merged 1 commit into from Apr 26, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -153,6 +153,7 @@ export default function fetch(url, opts) {
method: request.method,
body: request.body,
signal: request.signal,
timeout: request.timeout
};

// HTTP-redirect fetch step 9
@@ -275,6 +275,14 @@ export default class TestServer {
}, 1000);
}

if (p === '/redirect/slow-chain') {
res.statusCode = 301;
res.setHeader('Location', '/redirect/slow');
setTimeout(function() {
res.end();
}, 100);
}

if (p === '/redirect/slow-stream') {
res.statusCode = 301;
res.setHeader('Location', '/slow');
@@ -799,6 +799,17 @@ describe('node-fetch', () => {
});
});

it('should allow custom timeout on redirected requests', function() {
this.timeout(2000);
const url = `${base}redirect/slow-chain`;
const opts = {
timeout: 200
};
return expect(fetch(url, opts)).to.eventually.be.rejected
.and.be.an.instanceOf(FetchError)
.and.have.property('type', 'request-timeout');
});

it('should clear internal timeout on fetch response', function (done) {
this.timeout(2000);
spawn('node', ['-e', `require('./')('${base}hello', { timeout: 10000 })`])
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.