Skip to content

Commit

Permalink
backport fix from patriksimek#16 into CoffeeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
benvium committed Apr 3, 2018
1 parent bcd49e9 commit aa104e5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/store.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,20 @@ module.exports = (session) ->
_ready: (callback) ->
if @connection.connected then return callback.call @
if @connection.connecting then return @connection.once 'connect', callback.bind @
callback.call @, new Error "Connection is closed."


# Workaround for Connection is closed issue from https://github.com/patriksimek/connect-mssql/issues/16
try
current_instance = this
@connection.connect().then(->
callback.call current_instance
).catch (error) ->
console.error 'Unable to reopen closed connection', error
callback.call @, new Error error.message
catch error
console.error 'Unable to reopen closed connection', error
callback.call @, new Error 'Connection is closed.'
return

###
Attempt to fetch session by the given `sid`.
Expand Down

0 comments on commit aa104e5

Please sign in to comment.