Created
January 9, 2020 10:39
-
-
Save richardscarrott/6d02efb0a150aa36d5e1ab793d921e4a to your computer and use it in GitHub Desktop.
HTTP retry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With POST, and without
flushHeaders
(request done usingfetch
in Chrome console) the browser does not repeat the request and HANDLING REQUEST is printed only once)