Closed viniciusteixeiradias closed 1 year ago
Hi @viniciusteixeiradias ,
this is very strange!
This is the only call to unref
in the source code.
Could it be, in your project, something replaces the setTimeout
builtin function?
@iccicci I don't think it can be in my code. I'll check the project settings, but today the "rotating-file-stream" code is just this:
I am using vue 3 and typescript
import type { InjectionKey } from 'vue'
import { Logger, ILogObj } from "tslog";
import { createStream } from "rotating-file-stream";
const stream = createStream('tslog.log', {
size: "10M",
compress: "gzip",
interval: '1d',
});
const logger: Logger<ILogObj> = new Logger({ type: "hidden", hideLogPositionForProduction: true });
logger.attachTransport((logObj) => {
stream.write(JSON.stringify(logObj) + "\n");
});
const key = Symbol() as InjectionKey<Logger<ILogObj>>
export { logger, key };
The portion of code you pasted is fine, TypeScript is fine, I don't know vue, but it should be fine as well.
When I spoken about your project I was not speaking directly about your code, maybe some other packages...
Please check this two lines of code; the built-in setTimeout
function returns an object which has an unref
method, the only explaination coming to my mind for the problem is you reported is that something replaced the built-in setTimeout
function with anouther function which returns something else.
I created a project from scratch to validate if the error still persists. The error remains the same, if you want to test: https://github.com/viniciusteixeiradias/issue-rotate-file-system
The rotate-file-system config https://github.com/viniciusteixeiradias/issue-rotate-file-system/blob/main/src/App.vue
@iccicci , quick question... Does rotating-file-stream
run on the browser?
Nope @leviplj , it is designed only for Node.js, it doesn't implement writing files from browsers; it takes advantage from Node.js libraries to hadle files IO.
@iccicci "Universal: Works in Browsers and Node.js"?
@viniciusteixeiradias I don't know universal
@iccicci Yes sorry. It's just that I was using the ts-log lib and they indicate using rotate-file-system, ts-log runs in browsers, but apparently rotate-file-system does not. The only problem I had was with the interval, but since it's not browser compatible, I closed the issue.
Guys, I installed this lib in my project to help me with the log storage work, but I'm stuck in an error. I added the simplest configuration to my project and every time I see the system compile, I get the following error:
I could be doing some wrong configuration, I already looked in the doc and in other issues but I didn't find it, I hope you can help me :).
My code: