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

Error on Koa.js with bunyan #23

Open
koalex opened this issue Nov 15, 2021 · 1 comment
Open

Error on Koa.js with bunyan #23

koalex opened this issue Nov 15, 2021 · 1 comment

Comments

@koalex
Copy link

koalex commented Nov 15, 2021

On this code:

const Koa = require('koa');
const bunyan = require('bunyan');
const {clsProxify} = require('cls-proxify');
const {clsProxifyKoaMiddleware} = require('cls-proxify/integration/koa');

const app = new Koa();

const logger = bunyan.createLogger({
  name: 'cls-test',
  streams: [
    {
      level: 'error',
      stream: process.stderr,
    },
  ]
});

const loggerCls = clsProxify('clsKeyLogger', logger);

app.use(clsProxifyKoaMiddleware('clsKeyLogger', (ctx) => {
  return logger.child({
    requestId: Math.random(),
    level: 'error',
  });
}));

app.use(async (ctx, next) => {
  try {
    await next();
  } catch (err) {
    loggerCls.error(err);
  }
});

app.use(async ctx => {
  ctx.throw(new Error('boom'));
});

app.listen(3000, () => { console.log('Server listening on port', 3000); });

I'm got an error:

 TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received undefined
      at new NodeError (node:internal/errors:278:15)
      at WriteStream.Writable.write (node:internal/streams/writable:322:13)
@aigoncharov
Copy link
Owner

@koalex if the issue still stands, would it be too much to ask for a reproducer on repl.it?

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

No branches or pull requests

2 participants