Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit a7e9e2b8
authored
Mar 20, 2018
by
Christian Holm
Committed by
Sushant
Mar 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(transaction): only rollback if connection was acquired (#9051)
1 parent
ec0cb5ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
7 deletions
lib/transaction.js
test/integration/pool.test.js
lib/transaction.js
View file @
a7e9e2b
...
...
@@ -121,13 +121,15 @@ class Transaction {
this
.
connection
=
connection
;
this
.
connection
.
uuid
=
this
.
id
;
})
.
then
(()
=>
this
.
begin
())
.
then
(()
=>
this
.
setDeferrable
())
.
then
(()
=>
this
.
setIsolationLevel
())
.
then
(()
=>
this
.
setAutocommit
())
.
catch
(
setupErr
=>
this
.
rollback
().
finally
(()
=>
{
throw
setupErr
;
}))
.
then
(()
=>
{
return
this
.
begin
()
.
then
(()
=>
this
.
setDeferrable
())
.
then
(()
=>
this
.
setIsolationLevel
())
.
then
(()
=>
this
.
setAutocommit
())
.
catch
(
setupErr
=>
this
.
rollback
().
finally
(()
=>
{
throw
setupErr
;
}));
})
.
tap
(()
=>
{
if
(
useCLS
&&
this
.
sequelize
.
constructor
.
_cls
)
{
this
.
sequelize
.
constructor
.
_cls
.
set
(
'transaction'
,
this
);
...
...
test/integration/pool.test.js
View file @
a7e9e2b
...
...
@@ -33,4 +33,22 @@ describe(Support.getTestDialectTeaser('Pooling'), function() {
return
expect
(
this
.
testInstance
.
authenticate
())
.
to
.
eventually
.
be
.
rejectedWith
(
'ResourceRequest timed out'
);
});
it
(
'should not result in unhandled promise rejection when unable to acquire connection'
,
()
=>
{
this
.
testInstance
=
new
Sequelize
(
'localhost'
,
'ffd'
,
'dfdf'
,
{
dialect
,
databaseVersion
:
'1.2.3'
,
pool
:
{
acquire
:
1000
,
max
:
1
}
});
this
.
sinon
.
stub
(
this
.
testInstance
.
connectionManager
,
'_connect'
)
.
returns
(
new
Sequelize
.
Promise
(()
=>
{}));
return
expect
(
this
.
testInstance
.
transaction
()
.
then
(()
=>
this
.
testInstance
.
transaction
()))
.
to
.
eventually
.
be
.
rejectedWith
(
'ResourceRequest timed out'
);
});
});
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment