Skip to content

Commit fbc11b6

Browse files
committed
Added timeout {Number} property into the NEWACTION method.
1 parent 3b7f4bb commit fbc11b6

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

builders.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Total.js Builders
22
// The MIT License
3-
// Copyright 2023 (c) Peter Širka <petersirka@gmail.com>
3+
// Copyright 2023-2026 (c) Peter Širka <petersirka@gmail.com>
44

55
'use strict';
66

@@ -1405,6 +1405,7 @@ ActionCaller.prototype.exec = function() {
14051405
let type = meta.payload || (action.input ? '+' : '-');
14061406
let $ = self.$;
14071407

1408+
$.$end = false;
14081409
$.name = action.name;
14091410
$.id = action.id;
14101411
$.error = self.error;
@@ -1416,6 +1417,16 @@ ActionCaller.prototype.exec = function() {
14161417

14171418
$.$callback = function(err, response) {
14181419

1420+
if ($.$end)
1421+
return;
1422+
1423+
$.$end = true;
1424+
1425+
if ($.$timeout) {
1426+
clearTimeout($.$timeout);
1427+
$.$timeout = null;
1428+
}
1429+
14191430
if (!err) {
14201431
if (action.jsoutput)
14211432
response = action.jsoutput.transform(response).response;
@@ -1514,6 +1525,12 @@ ActionCaller.prototype.exec = function() {
15141525
if (self.options.progress)
15151526
$.progress2 = self.options.progress;
15161527

1528+
if (action.timeout) {
1529+
$.$timeout = setTimeout(function() {
1530+
$.invalid('Timeout.');
1531+
}, action.timeout);
1532+
}
1533+
15171534
if (action.middleware) {
15181535
action.middleware.wait(function(name, next) {
15191536
let fn = F.routes.middleware[name];

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- added a new global methods `AIMODEL()` and `NEWAIMODEL()`
2525
- added `exec` command to the remote editing functionality
2626
- always set `cwd` directory for the current executed script
27+
- added `timeout {Number}` property into the `NEWACTION` method
2728

2829
========================
2930
0.0.15

0 commit comments

Comments
 (0)