Skip to content

Commit

Permalink
remove stray error handling changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Jan 17, 2024
1 parent ffeead4 commit 8743dcb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/mongo_logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ function defaultLogTransform(
return log;
case SERVER_SELECTION_FAILED:
log = attachServerSelectionFields(log, logObject, maxDocumentLength);
log.failure = logObject.failure?.message;
log.failure = logObject.failure.message;
return log;
case SERVER_SELECTION_SUCCEEDED:
log = attachServerSelectionFields(log, logObject, maxDocumentLength);
Expand All @@ -536,7 +536,7 @@ function defaultLogTransform(
log = attachCommandFields(log, logObject);
log.message = 'Command failed';
log.durationMS = logObject.duration;
log.failure = logObject.failure?.message ?? '(redacted)';
log.failure = logObject.failure.message ?? '(redacted)';
return log;
case CONNECTION_POOL_CREATED:
log = attachConnectionFields(log, logObject);
Expand Down Expand Up @@ -666,7 +666,7 @@ function defaultLogTransform(
log = attachServerHeartbeatFields(log, logObject);
log.message = 'Server heartbeat failed';
log.durationMS = logObject.duration;
log.failure = logObject.failure?.message;
log.failure = logObject.failure.message;
return log;
case TOPOLOGY_OPENING:
log = attachSDAMFields(log, logObject);
Expand Down
20 changes: 0 additions & 20 deletions test/unit/mongo_client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,26 +864,6 @@ describe('MongoOptions', function () {
});
});

context('when option is not a valid MongoDBLogwritable stream', function () {
it('should default to stderr', function () {
const writable = {
buffer: [],
misNamedWrite(log) {
this.buffer.push(log);
}
};
const client = new MongoClient('mongodb://a/', {
[loggerFeatureFlag]: true,
mongodbLogPath: writable
});
const log = { t: new Date(), c: 'constructorInvalidOption', s: 'error' };
client.options.mongoLoggerOptions.logDestination.write(log);
expect(stderrStub.write).calledWith(
inspect(log, { breakLength: Infinity, compact: true })
);
});
});

context('when option is `stdout`', function () {
it('it is accessible through mongoLogger.logDestination', function () {
const client = new MongoClient('mongodb://a/', {
Expand Down

0 comments on commit 8743dcb

Please sign in to comment.