Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/mongodb-runner/src/mongoserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { Document, MongoClientOptions } from 'mongodb';
import { MongoClient } from 'mongodb';
import path from 'path';
import { once } from 'events';
import { uuid, debug, pick } from './util';
import { uuid, debug, pick, debugVerbose } from './util';

export interface MongoServerOptions {
binDir?: string;
Expand Down Expand Up @@ -197,10 +197,10 @@ export class MongoServer {
await once(outStream, 'open');
stdout.pipe(outStream, { end: false });
stderr.pipe(outStream, { end: false });
Promise.all([once(stdout, 'end'), once(stderr, 'end')]).then(
Promise.allSettled([once(stdout, 'end'), once(stderr, 'end')]).then(
() => outStream.end(),
() => {
/* ignore error */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still not ignoring an error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.allSettled() never rejects, hence the change in description here – the behavior is similar (but now we always wait for both stdout and stderr to be closed successfully instead of one of them potentially closing because of an error)

/* cannot throw */
},
);
} else {
Expand All @@ -211,13 +211,13 @@ export class MongoServer {

const errorLogEntries: LogEntry[] = [];
try {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const logEntryStream = Readable.from(createLogEntryIterator(stdout));
logEntryStream.on('data', (entry) => {
if (!srv.closing && ['E', 'F'].includes(entry.severity)) {
errorLogEntries.push(entry);
debug('mongodb server output', entry);
}
debugVerbose('mongodb server log entry', entry);
});
filterLogStreamForBuildInfo(logEntryStream).then(
(buildInfo) => {
Expand Down
1 change: 1 addition & 0 deletions packages/mongodb-runner/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BSON } from 'mongodb';
import createDebug from 'debug';

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