Skip to content

Commit 16990d6

Browse files
daria's comments
1 parent 8f7ecc9 commit 16990d6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/cmap/connect.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,10 @@ export async function performInitialHandshake(
199199
if (error instanceof MongoError) {
200200
error.addErrorLabel(MongoErrorLabel.HandshakeError);
201201
}
202-
// If we encounter an error executing the initial handshake, apply backpressure labels.
203-
applyBackpressureLabels(error);
202+
// If we encounter a network error executing the initial handshake, apply backpressure labels.
203+
if (error instanceof MongoNetworkError) {
204+
applyBackpressureLabels(error);
205+
}
204206

205207
throw error;
206208
}
@@ -437,7 +439,9 @@ export async function makeSocket(options: MakeConnectionOptions): Promise<Stream
437439
socket = await connectedSocket;
438440
return socket;
439441
} catch (error) {
440-
// If we encounter a SystemOverloaded error while establishing a socket, apply the backpressure labels to it.
442+
// If we encounter an error while establishing a socket, apply the backpressure labels to it. We cannot
443+
// differentiate between DNS, TLS errors and network errors without refactoring our connection establishment to
444+
// handle all three steps separately.
441445
applyBackpressureLabels(error);
442446
socket.destroy();
443447
throw error;

0 commit comments

Comments
 (0)