Skip to content

Commit c9a4834

Browse files
committed
Checking if last message was login before send reset on verifyConnectivity
1 parent cd2458b commit c9a4834

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

packages/bolt-connection/src/bolt/bolt-protocol-v1.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export default class BoltProtocol {
7979
this._log = log
8080
this._onProtocolError = onProtocolError
8181
this._fatalError = null
82+
this._lastMessageSignature = null
8283
}
8384

8485
/**
@@ -356,6 +357,8 @@ export default class BoltProtocol {
356357
this._log.debug(`C: ${message}`)
357358
}
358359

360+
this._lastMessageSignature = message.signature
361+
359362
this.packer().packStruct(
360363
message.signature,
361364
message.fields.map(field => this.packer().packable(field))
@@ -369,6 +372,10 @@ export default class BoltProtocol {
369372
}
370373
}
371374

375+
isLastMessageLogin () {
376+
return this._lastMessageSignature === 0x01
377+
}
378+
372379
/**
373380
* Notifies faltal erros to the observers and mark the protocol in the fatal error state.
374381
* @param {Error} error The error

packages/bolt-connection/src/connection-provider/connection-provider-pooled.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default class PooledConnectionProvider extends ConnectionProvider {
123123
const connection = await this._connectionPool.acquire(address)
124124
const serverInfo = new ServerInfo(connection.server, connection.protocol().version)
125125
try {
126-
if (!connection._firstUsage) {
126+
if (!connection._firstUsage && !connection.protocol().isLastMessageLogin()) {
127127
await connection.resetAndFlush()
128128
}
129129
} finally {

packages/bolt-connection/test/connection-provider/connection-provider-direct.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe('.verifyConnectivityAndGetServerInfo()', () => {
251251
const create = (address, release) => {
252252
const connection = new FakeConnection(address, release, server)
253253
connection.protocol = () => {
254-
return { version: protocolVersion }
254+
return { version: protocolVersion, isLastMessageLogin() { return false } }
255255
}
256256
connection.resetAndFlush = resetAndFlush
257257
if (releaseMock) {

packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3103,7 +3103,8 @@ class FakeConnection extends Connection {
31033103

31043104
protocol () {
31053105
return {
3106-
version: this._protocolVersion
3106+
version: this._protocolVersion,
3107+
isLastMessageLogin: () => this._firstUsage
31073108
}
31083109
}
31093110
}

0 commit comments

Comments
 (0)