@sap/cds 8.9.7 → 8.9.8
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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
- The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
5
5
|
- This project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## Version 8.9.8 - 2025-12-17
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- `enterprise-messaging-shared`: preserve error listener during reconnect
|
|
12
|
+
|
|
7
13
|
## Version 8.9.7 - 2025-11-07
|
|
8
14
|
|
|
9
15
|
### Fixed
|
|
@@ -1,64 +1,66 @@
|
|
|
1
1
|
const waitingTime = require('../../common/utils/waitingTime')
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.then(() => {
|
|
8
|
-
LOG._warn && LOG.warn('Reconnected to Enterprise Messaging Client')
|
|
9
|
-
})
|
|
10
|
-
.catch(() => {
|
|
11
|
-
LOG._warn &&
|
|
12
|
-
LOG.warn(
|
|
13
|
-
`Connection to Enterprise Messaging Client lost: Reconnecting in ${Math.round(_waitingTime / 1000)} s`
|
|
14
|
-
)
|
|
15
|
-
_connectUntilConnected(client, LOG, x + 1)
|
|
16
|
-
})
|
|
17
|
-
}, _waitingTime)
|
|
3
|
+
const _rmHandlers = client => {
|
|
4
|
+
client.removeAllListeners('connected')
|
|
5
|
+
client.removeAllListeners('error')
|
|
6
|
+
client.removeAllListeners('disconnected')
|
|
18
7
|
}
|
|
19
8
|
|
|
20
9
|
const connect = (client, LOG, keepAlive) => {
|
|
21
10
|
return new Promise((resolve, reject) => {
|
|
11
|
+
_rmHandlers(client)
|
|
12
|
+
|
|
22
13
|
client
|
|
23
14
|
.once('connected', function () {
|
|
24
|
-
client
|
|
15
|
+
_rmHandlers(client)
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
LOG.error(err)
|
|
30
|
-
}
|
|
31
|
-
if (keepAlive) {
|
|
32
|
-
client.removeAllListeners('error')
|
|
33
|
-
client.removeAllListeners('connected')
|
|
34
|
-
_connectUntilConnected(client, LOG, 0)
|
|
35
|
-
}
|
|
36
|
-
})
|
|
17
|
+
// It's important to _always_ keep an error listener,
|
|
18
|
+
// otherwise it will throw and crash the server
|
|
19
|
+
client.on('error', err => LOG(err?.message))
|
|
37
20
|
|
|
38
21
|
if (keepAlive) {
|
|
39
|
-
client.
|
|
40
|
-
|
|
41
|
-
client.
|
|
42
|
-
|
|
22
|
+
client.on('disconnected', () => {
|
|
23
|
+
let connected = false
|
|
24
|
+
client.once('connected', () => {
|
|
25
|
+
LOG('Reconnected')
|
|
26
|
+
connected = true
|
|
27
|
+
})
|
|
28
|
+
let x = 1
|
|
29
|
+
const _untilConnected = async () => {
|
|
30
|
+
if (!connected) {
|
|
31
|
+
LOG('Reconnecting')
|
|
32
|
+
try {
|
|
33
|
+
client.connect()
|
|
34
|
+
} catch {
|
|
35
|
+
// we try again...
|
|
36
|
+
}
|
|
37
|
+
setTimeout(_untilConnected, waitingTime(x++))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
_untilConnected()
|
|
43
41
|
})
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
resolve(
|
|
44
|
+
resolve(client)
|
|
47
45
|
})
|
|
48
46
|
.once('error', err => {
|
|
49
|
-
client
|
|
50
|
-
|
|
47
|
+
_rmHandlers(client)
|
|
48
|
+
const e = new Error('Connection error')
|
|
49
|
+
e.cause = err
|
|
50
|
+
reject(e)
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
try {
|
|
54
|
+
client.connect()
|
|
55
|
+
} catch (e) {
|
|
56
|
+
reject(e)
|
|
57
|
+
}
|
|
54
58
|
})
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
const disconnect = client => {
|
|
58
62
|
return new Promise((resolve, reject) => {
|
|
59
|
-
client
|
|
60
|
-
client.removeAllListeners('connected')
|
|
61
|
-
client.removeAllListeners('error')
|
|
63
|
+
_rmHandlers(client)
|
|
62
64
|
|
|
63
65
|
client.once('disconnected', () => {
|
|
64
66
|
client.removeAllListeners('error')
|