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();
|
var connector = this.getConnector();
|
||||||
Transaction.begin(connector, options, function(err, transaction) {
|
Transaction.begin(connector, options, function(err, transaction) {
|
||||||
if (err) return cb(err);
|
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
|
// Set an informational transaction id
|
||||||
transaction.id = uuid.v1();
|
transaction.id = uuid.v1();
|
||||||
}
|
}
|
||||||
if (options.timeout) {
|
if (options.timeout && !transaction.timeout) {
|
||||||
setTimeout(function() {
|
transaction.timeout = setTimeout(function() {
|
||||||
var context = {
|
var context = {
|
||||||
transaction: transaction,
|
transaction: transaction,
|
||||||
operation: 'timeout',
|
operation: 'timeout',
|
||||||
|
|
Loading…
Reference in New Issue