winstonjs/winston
View on GitHubjest is detecting memory leaks when creating a logger with a `File` transport
Open
#1445 opened on Aug 22, 2018
Help WantedNeeds Investigation
Description
Please tell us about your environment:
- _
winstonversion? winston@3 - _
node -voutputs: v10.9.0 - _Operating System? macOS 10.13.6
- _Language? Typescript 3.0.1
What is the problem?
Jest --detectLeaks (experimental flag) is reporting that winston is leaking when using the File transport.
import winston from "winston";
describe("winston", () => {
it(`should not leak memory with a file transport`, async () => {
const logger = winston.createLogger({
transports: [
new winston.transports.File({
filename: "logs/error.log",
level: "error"
})
]
});
logger.close();
expect(logger).toBeTruthy();
});
});
jest --detectLeaks
FAIL ./file-transport.spec.ts
● Test suite failed to run
EXPERIMENTAL FEATURE!
Your test suite is leaking memory. Please ensure all references are cleaned.
There is a number of things that can leak memory:
- Async operations that have not finished (e.g. fs.readFile).
init
- Timers not properly mocked (e.g. setInterval, setTimeout).
- Keeping references to the global scope.
at node_modules/jest-cli/build/TestScheduler.js:275:22
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.654s
Other information
Can be reproduced on this repository: https://github.com/shusson/winston-leak