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

winston-transport this.once in the code causes app to crash. #212

Open
1 of 2 tasks
bobj82 opened this issue Nov 1, 2021 · 2 comments
Open
1 of 2 tasks

winston-transport this.once in the code causes app to crash. #212

bobj82 opened this issue Nov 1, 2021 · 2 comments
Labels

Comments

@bobj82
Copy link

bobj82 commented Nov 1, 2021

Please tell us about your environment:

  • winston version?
    • winston@2
    • winston@3

./package.json

"dependencies": {
"comment":"irrelevant entries removed",
      "winston": "^3.3.3",
      "winston-mongodb": "^5.0.7",
      "winston-syslog": "^2.4.4"
   },
  • _node -v outputs:_v16.13.0
  • Operating System? macOS
  • _Language? ES6/7

What is the problem?

I installed and configured winston-mongodb. When I tried to run the app, it crashed. Below are the details. I tried to fix it myself on the local copy, but it contiues to fail. So, I'm sending an issue instead of generating a pull request.

What do you expect to happen instead?

The app to start and send logs to mongodb.

Error message

 node .
/Users/bob/git/CPESN/Sandbox/passport_workspace/node_modules/winston-transport/index.js:32
  this.once('pipe', logger => {
       ^

TypeError: this.once is not a function
    at Object.TransportStream (/Users/bob/git/CPESN/Sandbox/passport_workspace/node_modules/winston-transport/index.js:32:8)
    at Object.exports.MongoDB (/Users/bob/git/CPESN/Sandbox/passport_workspace/node_modules/winston-mongodb/lib/winston-mongodb.js:56:13)
    at Object.<anonymous> (/Users/bob/git/CPESN/Sandbox/passport_workspace/logger.js:132:16)
    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)
    at Object.<anonymous> (/Users/bob/git/CPESN/Sandbox/passport_workspace/server.js:9:16)

Possible Solution:

I checked the core winston code. It includes a dependency for 'one-time'. So, I tried inserting it into my copy of winston-transport/index.js in the hopes of simply using a pull request. But, I apparently did it wrong because the code still fails. I'm willing to do the pull request if you tell me how to get it working.

Changes I Tried

winston-transport/package.json
"dependencies": {
                "one-time": "^1.0.0",
                "readable-stream": "^2.3.7",
                "triple-beam": "^1.2.0"
        },
winston-transport/index.js
const { LEVEL } = require('triple-beam');
const once = require('one-time');

Implementation Excerpts

./server.js

const logger = require('./logger.js');

./logger.js

const winston = require('winston');
const { transports, format } = winston;
require('winston-mongodb');
@SnakeFighter
Copy link

Did you ever get to the bottom of this, @bobj82 ? I;ve just run into the issue myself.

@wbt wbt transferred this issue from winstonjs/winston Dec 9, 2022
@wbt
Copy link

wbt commented Dec 9, 2022

Not 100% sure if the transfer is correct, but if not, we can move it back.

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

No branches or pull requests

4 participants