New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

http-delayed-response

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-delayed-response - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

10

HISTORY.md

@@ -0,4 +1,7 @@

0.0.3 / March 4 2014
========================
* minor update to "stop", making sure it always get called
0.0.2 / February 20 2014
=======================
========================
* added new method: "wait"

@@ -9,5 +12,4 @@ * added support for "timeout"

0.0.1 / February 18 2014
=======================
========================
* initial release
* experimental status

15

index.js

@@ -34,2 +34,6 @@ var stream = require('stream');

});
// make sure timers stop if response is closed
res.on('close', function () {
delayed.stop();
});

@@ -161,2 +165,5 @@ EventEmitter.call(this);

// restore socket buffering
this.res.socket && this.res.socket.setNoDelay(false);
// handle an error

@@ -196,9 +203,9 @@ if (err) {

// stop polling
this.pollingTimer && clearInterval(this.pollingTimer);
clearInterval(this.pollingTimer);
this.pollingTimer = null;
// stop timeout
this.timeout && clearTimeout(this.timeout);
// restore socket buffering
this.res.socket && this.res.socket.setNoDelay(false);
clearTimeout(this.timeout);
this.timeout = null;
};
module.exports = DelayedResponse;
{
"name": "http-delayed-response",
"version": "0.0.2",
"version": "0.0.3",
"author": {

@@ -5,0 +5,0 @@ "name": "Nicolas Mercier",

@@ -101,3 +101,3 @@ # http-delayed-response

delayed.json();
// starting will write to the body - headers must be set before
// start activates long-polling - headers must be set before
verySlowFunction(delayed.start());

@@ -148,4 +148,6 @@ });

res.end();
}).wait();
});
slowFunction(delayed.wait());
});

@@ -156,6 +158,4 @@ ```

To handle errors, use the "error" event. Otherwise, unhandled errors will be thrown. When using long-polling, HTTP status 202 is already applied and the HTTP protocol has no mechanism to indicate an error past this point. Also, when handling errors, you are responsible for ending the response.
To handle errors, use the "error" event. Otherwise, unhandled errors will be thrown. Timeouts that are not handled with a "cancel" event are treated like normal errors. When using long-polling, HTTP status 202 is already applied and the HTTP protocol has no mechanism to indicate an error past this point. Also, when handling errors, you are responsible for ending the response.
Also, a timeout that is not handled with a "cancel" event is treated like a normal error.
```js

@@ -180,3 +180,3 @@ app.use(function (req, res) {

var delayed = new DelayedResponse(req, res, next);
// "next" will be invoked if "slowFunction" fails or times out
// "next" will be invoked if "slowFunction" fails or take longer than 1 second to return
slowFunction(delayed.wait(1000));

@@ -199,3 +199,3 @@ });

// wait indefinitely
// wait indefinitely - client might get bored...
slowFunction(delayed.wait());

@@ -250,4 +250,6 @@

Returns a callback handler that must be invoked within the allocated time.
Returns a callback handler that must be invoked within the allocated time represented by `timeout`.
The returned handler is the same as calling `DelayedResponse.end`.
#### DelayedResponse.start(interval, initialDelay, timeout)

@@ -263,7 +265,7 @@

Stops waiting and sends the response contents represented by `data` - or invoke the error handler if an error is present.
Stops waiting, sending the contents represented by `data` in the response - or invoke the error handler if an error is present.
#### DelayedResponse.stop()
Stops long polling and timeout timers without affecting the response.
Stops monitoring timers without affecting the response.

@@ -276,11 +278,11 @@ #### DelayedResponse.json()

Fired when `end` is invoked without an error.
Fired when `end` is invoked without an error. If this event is not handled, the callback result is written in the response.
#### Event: 'cancel'
#### Event: 'error'
Fired when `end` failed to be invoked within the allocated time.
Fired when `end` is invoked with an error. If this event is not handled, the error is thrown as an uncaught error.
#### Event: 'error'
#### Event: 'cancel'
Fired when `end` is invoked with an error, or when an unhandled timeout occurs.
Fired when `end` failed to be invoked within the allocated time. If this event is not handled, the timeout is considered a normal error that can be handled using the `error` event.

@@ -287,0 +289,0 @@ #### Event: 'abort'

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc