-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Fully Compatible
-
ALL
-
Service Arch 2021-12-13, Service Arch 2022-1-10
-
3
Here: https://github.com/mongodb/mongo/blob/6e98a462d6e3f2222bc53bc948b60721e7879999/jstests/noPassthrough/socket_disconnect_kills.js#L41-L49 the test socket_disconnect_kills.js tries to run some operation over a Mongo connection and wants to check that it fails with a network error (here's the linked code in a snippet):
// Make sure that whatever operation we ran had a network error assert.throws(function() { try { pre(conn); } catch (e) { throw e; } }, [], "error doing query: failed: network error while attempting");
However, this block of code doesn't actually check that the operation fails with a network error – it just checks that it fails at all (i.e. that pre(conn) throws). The provided "message" third argument to assert.throws is just the message to print if the assertion fails (i.e. if the pre(conn) didn't throw). We need to actually inspect the Error object returned by assert.throws and ensure it's a network error to realize the intent of this test.