Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Winston #1128

Merged
merged 3 commits into from
Jan 14, 2022
Merged

Upgrade Winston #1128

merged 3 commits into from
Jan 14, 2022

Conversation

MatrixFrog
Copy link
Contributor

@MatrixFrog MatrixFrog commented Jan 12, 2022

Didn't really test this other than running npm run test; let me know if there's anything else I should try out.

lib/forever/cli.js Outdated Show resolved Hide resolved
@MatrixFrog MatrixFrog requested a review from kibertoad January 13, 2022 00:05
@MatrixFrog
Copy link
Contributor Author

I think this should be good to go, let me know if you have any other questions on it!

@kibertoad kibertoad merged commit a0fb120 into foreversd:master Jan 14, 2022
@kibertoad
Copy link
Contributor

Thank you! Will release a new version today.

@2naive
Copy link

2naive commented Jan 28, 2022

@kibertoad still waiting :)

@kibertoad
Copy link
Contributor

ouch. will do it right now, thank you for the ping.

@kibertoad
Copy link
Contributor

Released in 4.0.3

@2naive
Copy link

2naive commented Jan 28, 2022

@kibertoad thanks,
but @MatrixFrog I cannot confirm it fixes #1077

NODE_OPTIONS='--trace-warnings' forever list
info:    No forever processes running
(node:1836) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
    at emitCircularRequireWarning (node:internal/modules/cjs/loader:707:11)
    at Object.get (node:internal/modules/cjs/loader:721:5)
    at Object.exports.setLevels (/usr/local/lib/node_modules/forever/node_modules/cliff/node_modules/winston/lib/winston/common.js:32:14)
    at Object.<anonymous> (/usr/local/lib/node_modules/forever/node_modules/cliff/node_modules/winston/lib/winston.js:83:8)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
(node:1836) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
    at emitCircularRequireWarning (node:internal/modules/cjs/loader:707:11)
    at Object.get (node:internal/modules/cjs/loader:721:5)
    at Object.exports.setLevels (/usr/local/lib/node_modules/forever/node_modules/broadway/node_modules/winston/lib/winston/common.js:32:14)
    at Object.<anonymous> (/usr/local/lib/node_modules/forever/node_modules/broadway/node_modules/winston/lib/winston.js:82:8)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)

node -v
v16.13.2
npm view forever
forever@4.0.3

@kibertoad
Copy link
Contributor

/usr/local/lib/node_modules/forever/node_modules/cliff/node_modules/winston/lib/winston.js

Looks like it is coming as a transitive dependency from cliff, so we'd need to get rid of that too.

@2naive
Copy link

2naive commented Jan 28, 2022

@kibertoad and broadway

@kibertoad
Copy link
Contributor

pretty sure we removed broadway already, is it coming as transitive from somewhere too?

@2naive
Copy link

2naive commented Jan 28, 2022

@kibertoad
/usr/local/lib/node_modules/forever/node_modules/broadway/node_modules/winston/lib/winston.js

as you may see in second warning above

@kibertoad
Copy link
Contributor

yeah, looks like flatiron is bringing it

@2naive
Copy link

2naive commented Jan 29, 2022

A bit deeper: #1077 (comment)

@MatrixFrog maybe you could solve this

@MatrixFrog
Copy link
Contributor Author

Well I can certainly try. The hardest part might be getting package owners to respond and merge stuff. Or maybe it's easier to just fork things as needed.

@2naive
Copy link

2naive commented Jan 29, 2022

I suppose if @kibertoad will change dependency -> would be better just to fork:
Broadway won't fallback to 0.x and Flatiron seems too dead.

@kibertoad
Copy link
Contributor

yeah, I'm happy to change to forks

@mmrwoods
Copy link

@MatrixFrog This seems to change in the output from forever --plain list, in a way that breaks forever-service on Amazon Linux 2 (and presumably other RHEL derivatives).

With forever v4.0.2, I get output like this:

info:    Forever processes running
data:        uid        command       script  forever pid  id logfile                 uptime
data:    [0] contentapi /usr/bin/node bin/www 7873    7927    /var/log/contentapi.log 75:20:4:18.05599999986589

With forever v4.0.3, I get output like this:

info:    Forever processes running
data:undefined    uid        command       script  forever pid  id logfile                 uptime
data:undefined[0] contentapi /usr/bin/node bin/www 8044    8113    /var/log/contentapi.log 0:0:16:20.09299999999996

That undefined after data: breaks the init script created by forever-service as it relies on a regex matching whitespace after data: to identify running services.

@MatrixFrog
Copy link
Contributor Author

I see that too on my machine (Ubuntu 21.10). Hopefully I'll have some time to look into it this week.

@MatrixFrog
Copy link
Contributor Author

It looks like the undefined is getting tacked on here https://github.com/winstonjs/logform/blob/master/pad-levels.js#L64

Quick fix might be to switch 'data' to 'info' at: https://github.com/foreversd/forever/blob/master/lib/forever/cli.js#L433 though of course you still might have to update your regex :(

@mmrwoods
Copy link

Thanks @MatrixFrog, I'm just a user of forever and forever-service, and for now I have pinned forever to 4.0.2, but I'll open an issue on forever-service and reference these comments.

@MatrixFrog
Copy link
Contributor Author

filed winstonjs/winston#2053 -- I imagine the fix would be pretty easy if I was a little more familiar with the internals of Winston and its related packages.

@MatrixFrog
Copy link
Contributor Author

Proposed fix is out: winstonjs/logform#135
I guess you can 👍 it and maybe that will help get it merged

@mmrwoods
Copy link

mmrwoods commented Feb 3, 2022

Thanks for submitting the Winston PR, would be good to see the issue fixed upstream. Just wondering though... is it not the responsibility of forever to specify the log levels it wants to be available before trying to log with those levels? Would a quick update to the forever.out logger to specify the log levels as winston.config.cli.levels (as per forever.log) fix this issue?

@mmrwoods
Copy link

mmrwoods commented Feb 3, 2022

btw, I have added a +1 to the PR, though I did also wonder about the fix... that code has seemingly been in use for 4 years and nobody else has raised this as an issue, and the winston readme also states that the default value for the levels param when calling createLogger() is winston.config.npm.levels.

I should point out that I am really not a javascript developer, so everything I say or suggest here should be taken with a healthy pinch of salt.

@MatrixFrog
Copy link
Contributor Author

good point, i guess let's see what they say, and in the meantime yes it probably makes sense to pass the cli.levels in forever

@MatrixFrog
Copy link
Contributor Author

Proposed fix on the forever side, here #1130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants