session-sync-auth-site 4.0.10 → 4.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/setUpConnection.js +12 -2
package/package.json
CHANGED
package/src/setUpConnection.js
CHANGED
|
@@ -6,13 +6,22 @@ const setUpConnection = async ({
|
|
|
6
6
|
connectionObj,
|
|
7
7
|
}={}) => {
|
|
8
8
|
|
|
9
|
+
if(global.sessionSyncAuthSiteConnection) {
|
|
10
|
+
try {
|
|
11
|
+
await global.sessionSyncAuthSiteConnection.query(`SELECT 1`) // test the connection
|
|
12
|
+
} catch(err) {
|
|
13
|
+
console.error(`Connection (session-sync-auth-site: ${connectionObj.database || connectionObj.path[0]}) was present, but not working. Attempting to delete and re-establish it.`, err)
|
|
14
|
+
delete global.sessionSyncAuthSiteConnection
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
9
18
|
if(global.sessionSyncAuthSiteConnection) return
|
|
10
19
|
|
|
11
20
|
if(!global.sessionSyncAuthSiteConnectionPromise) {
|
|
12
21
|
|
|
13
22
|
global.sessionSyncAuthSiteConnectionPromise = (async () => {
|
|
14
23
|
|
|
15
|
-
console.log(
|
|
24
|
+
console.log(`Establishing DB connection (session-sync-auth-site: ${connectionObj.database || connectionObj.path[0]})...`)
|
|
16
25
|
|
|
17
26
|
connectionObj = connectionObj || new ConnectionString(connectionStr)
|
|
18
27
|
|
|
@@ -29,13 +38,14 @@ const setUpConnection = async ({
|
|
|
29
38
|
namedPlaceholders: true,
|
|
30
39
|
})
|
|
31
40
|
|
|
32
|
-
console.log(
|
|
41
|
+
console.log(`...DB connection (session-sync-auth-site: ${connectionObj.database || connectionObj.path[0]}) established.`)
|
|
33
42
|
|
|
34
43
|
})()
|
|
35
44
|
|
|
36
45
|
}
|
|
37
46
|
|
|
38
47
|
await global.sessionSyncAuthSiteConnectionPromise
|
|
48
|
+
delete global.sessionSyncAuthSiteConnectionPromise
|
|
39
49
|
|
|
40
50
|
}
|
|
41
51
|
|