Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure where it's gone, but an answer popped in here and disappeared with a link to <a href="https://github.com/andyet/paddle" rel="nofollow">https://github.com/andyet/paddle</a> - a small library designed to provide callback execution "insurance". At least it suggests I'm not the first person to have scratched my head regarding this problem.</p> <p>From the docs on there is an anecdote validating the question somewhat:</p> <blockquote> <p>Node.js famously had an http client but where occasionally no callback would occur for an HTTP request if the response was too fast. If I wanted to make sure my http client callback occurred.</p> </blockquote> <p>The example they give is a little more sophisticated than my example and can handle event based callbacks, enabling code to regularly "check in" as intermediate activity like an ondata handler fires and then trigger an error if it stops or times out.</p> <pre><code>setTimeout(function() { paddle.stop(); }, 12000); var req = http.get(options, function(res) { var http_insurance = paddle.insure(function(res) { console.log("The request never had body events!"); console.log('STATUS: ' + res.statusCode); console.log('HEADERS: ' + JSON.stringify(res.headers)); }, 9, [res]); res.setEncoding('utf8'); res.on('data', function (chunk) { console.log('BODY: ' + chunk); http_insurance.check_in(); }); }); req.end(); </code></pre> <p>I'm answering my own question here, but I would still be interested to see if any other implementations, libraries or patterns exist to solve the same problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload