Skip to content

Commit 1ce2020

Browse files
committed
fix(mongodb-runner): forward all server log entries to debug
In particular, enabling `mongodb-runner:verbose` debug logs lets you read all server logs. This should help debug the server setup errors we've been seeing in mongosh CI.
1 parent 464020e commit 1ce2020

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/mongodb-runner/src/mongoserver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { Document, MongoClientOptions } from 'mongodb';
1313
import { MongoClient } from 'mongodb';
1414
import path from 'path';
1515
import { once } from 'events';
16-
import { uuid, debug, pick } from './util';
16+
import { uuid, debug, pick, debugVerbose } from './util';
1717

1818
export interface MongoServerOptions {
1919
binDir?: string;
@@ -197,10 +197,10 @@ export class MongoServer {
197197
await once(outStream, 'open');
198198
stdout.pipe(outStream, { end: false });
199199
stderr.pipe(outStream, { end: false });
200-
Promise.all([once(stdout, 'end'), once(stderr, 'end')]).then(
200+
Promise.allSettled([once(stdout, 'end'), once(stderr, 'end')]).then(
201201
() => outStream.end(),
202202
() => {
203-
/* ignore error */
203+
/* cannot throw */
204204
},
205205
);
206206
} else {
@@ -211,13 +211,13 @@ export class MongoServer {
211211

212212
const errorLogEntries: LogEntry[] = [];
213213
try {
214-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
215214
const logEntryStream = Readable.from(createLogEntryIterator(stdout));
216215
logEntryStream.on('data', (entry) => {
217216
if (!srv.closing && ['E', 'F'].includes(entry.severity)) {
218217
errorLogEntries.push(entry);
219218
debug('mongodb server output', entry);
220219
}
220+
debugVerbose('mongodb server log entry', entry);
221221
});
222222
filterLogStreamForBuildInfo(logEntryStream).then(
223223
(buildInfo) => {

packages/mongodb-runner/src/util.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { BSON } from 'mongodb';
22
import createDebug from 'debug';
33

44
export const debug = createDebug('mongodb-runner');
5+
export const debugVerbose = debug.extend('verbose');
56
export const uuid = () => new BSON.UUID().toHexString(true);
67
export const sleep = (ms: number): Promise<void> =>
78
new Promise((r) => setTimeout(r, ms));

0 commit comments

Comments
 (0)