Total.js framework v5 is the framework for Node.js platform written in pure JavaScript similar to PHP's Laravel or Python's Django or ASP.NET MVC. It can be used as a web, desktop, service, or IoT application.
$ npm install total5REQUEST(opt) accepts an optional standard AbortSignal as opt.signal. RESTBuilder passes it through with the chainable .signal(signal) method:
var controller = new AbortController();
var pending = REQUEST({ url: 'https://example.com/data', signal: controller.signal });
// Or use RESTBuilder:
var builder = RESTBuilder.GET('https://example.com/data').signal(controller.signal);
var response = builder.promise();
controller.abort();Cancellation rejects a pending promise, or completes its callback once, with an error named AbortError and code ABORT_ERR. error.cause contains signal.reason. The existing callback/promise return values are unchanged. Configure the builder's signal before calling .exec(), .promise() or .stream().
An already-aborted signal prevents network I/O. Cancelling during DNS resolution prevents a later connection; it does not claim to cancel the operating system's DNS operation. Cancellation closes the current request and its owned upload/download/decompression streams, including requests made after redirects and HTTPS proxy setup. Shared keep-alive agents are not destroyed. One signal can cancel several requests.
For custom: true / .stream(), the callback is delivered once when headers arrive. The signal stays active until that response stream ends or closes. Aborting after headers destroys the stream with AbortError; consume its error event as with other Node.js streams. It does not call the already-delivered callback a second time. Completing an ordinary response or closing a custom stream removes its abort listener. Existing .timeout() behavior is unchanged; use AbortSignal.timeout(ms) if an absolute deadline must also cover the response body.
Run the focused tests with node --test tests/common/request-cancellation.js, or use npm test to include them in the framework suite.
Please support the framework on social networks.
