Conversation
|
Removing binding on the event emitter eliminates the error. import { type LogWriter } from '../types';
const createBlockingWriter = (stream: NodeJS.WritableStream): LogWriter => {
return (message: string) => {
stream.write(message + '\n');
};
};
export const createNodeWriter = (): LogWriter => {
// eslint-disable-next-line node/no-process-env
const targetStream = (process.env.ROARR_STREAM ?? 'STDOUT').toUpperCase();
const stream =
targetStream.toUpperCase() === 'STDOUT' ? process.stdout : process.stderr;
- stream.on('error', (error) => {
- if (error.code === 'EPIPE') {
- return;
- }
-
- throw error;
- });
return createBlockingWriter(stream);
};At a glance, I am not 100% sure why this is reported as a memory leak. |
|
I hit a similar (probably the same) issue resulting in the following warning during test execution: ExplanationFor each test module(file) Jest creates a new environment. Each environment has a clean global object, so when is loaded Good news is that the error is try/catch-ed, so it does not effect the test execution. That said, it would be best if there was a way to cleanup the |
This recreates the issue #79
Thank you to @ferrata for helping to create a replication of the issue https://github.com/ferrata/slonik-jest-memory-leak-demo