Skip to content

Commit 075a733

Browse files
committed
fix(logger): replace PassThrough with Writable for log handling CLOUDP-332732
1 parent 636c7b7 commit 075a733

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

packages/compass-web/src/logger.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Logger } from '@mongodb-js/compass-logging/provider';
22
import { MongoLogWriter } from 'mongodb-log-writer/mongo-log-writer';
3-
import { PassThrough } from 'stream';
3+
import type { Writable } from 'stream';
44
import { mongoLogId } from '@mongodb-js/compass-logging/provider';
55
import { useRef } from 'react';
66

@@ -62,13 +62,17 @@ export class CompassWebLogger implements Logger {
6262
};
6363
}
6464
) {
65-
const passThrough = new PassThrough({ objectMode: true });
66-
this.log = new MongoLogWriter('', '', passThrough).bindComponent(
67-
this.component
68-
);
69-
passThrough.on('data', (line) => {
70-
callbackRef.current.onLog?.(JSON.parse(line));
71-
});
65+
const target = {
66+
write(line: string, callback: () => void) {
67+
callbackRef.current.onLog?.(JSON.parse(line));
68+
callback();
69+
},
70+
end(callback: () => void) {
71+
callback();
72+
},
73+
} as Writable;
74+
75+
this.log = new MongoLogWriter('', '', target).bindComponent(this.component);
7276

7377
this.debug = createCompassWebDebugger(this.component, this.callbackRef);
7478
}

0 commit comments

Comments
 (0)