Transaction: Bind timeout to tx instance (#1484)
This commit is contained in:
parent
37e7f0c8ab
commit
94a602d17e
|
@ -76,12 +76,17 @@ TransactionMixin.beginTransaction = function(options, cb) {
|
|||
var connector = this.getConnector();
|
||||
Transaction.begin(connector, options, function(err, transaction) {
|
||||
if (err) return cb(err);
|
||||
if (transaction) {
|
||||
// NOTE(lehni) As part of the process of moving the handling of
|
||||
// transaction id and timeout from TransactionMixin.beginTransaction() to
|
||||
// Transaction.begin() in loopback-connector, switch to only setting id
|
||||
// and timeout if it wasn't taken care of already by Transaction.begin().
|
||||
// Eventually, we can remove the following two if-blocks altogether.
|
||||
if (!transaction.id) {
|
||||
// Set an informational transaction id
|
||||
transaction.id = uuid.v1();
|
||||
}
|
||||
if (options.timeout) {
|
||||
setTimeout(function() {
|
||||
if (options.timeout && !transaction.timeout) {
|
||||
transaction.timeout = setTimeout(function() {
|
||||
var context = {
|
||||
transaction: transaction,
|
||||
operation: 'timeout',
|
||||
|
|
Loading…
Reference in New Issue