Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HTTP retry
const express = require('express');
console.log(process.version);
const app = express();
app.get('/hello', (req, res) => {
console.log('HANDLING REQUEST');
res.setHeader('content-type', 'application/json');
res.flushHeaders(); // `flushHeaders` to prevent http client from retrying and therefore invoking this handler multiple times.
res.destroy();
});
app.listen(9000, () => {
console.log('Listening');
});
// https://blogs.oracle.com/ravello/beware-http-requests-automatic-retries
@nfcampos

This comment has been minimized.

Copy link

@nfcampos nfcampos commented Aug 12, 2020

With POST, and without flushHeaders (request done using fetch in Chrome console) the browser does not repeat the request and HANDLING REQUEST is printed only once)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment