pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.27k stars 150 forks source link

pino-pretty fails to load via Bun #448

Closed denis-guesty closed 1 year ago

denis-guesty commented 1 year ago

There is an issue with this package when running it via Bun, below is the stack trace.

124 |       return join(__dirname, '..', 'file.js')
125 |     }
126 |
127 |     let fixTarget
128 |
129 |     for (const filePath of callers) {
                               ^
TypeError: undefined is not an object (evaluating 'callers')
      at fixTarget (/Users/***/Workspace/bun-test/node_modules/pino/lib/transport.js:129:27)
      at transport (/Users//***/Workspace/bun-test/node_modules/pino/lib/transport.js:114:21)
      at normalizeArgs (/Users//***/Workspace/bun-test/node_modules/pino/lib/tools.js:311:15)
      at pino (/Users//***/Workspace/bun-test/node_modules/pino/pino.js:87:27)
      at /Users//***/Workspace/bun-test/server.ts:7:16
124 |       return join(__dirname, '..', 'file.js')
125 |     }
126 |
127 |     let fixTarget
128 |
129 |     for (const filePath of callers) {
                               ^
TypeError: undefined is not an object (evaluating 'callers')
      at fixTarget (/Users//***/Workspace/bun-test/node_modules/pino/lib/transport.js:129:27)
      at transport (/Users//***/Workspace/bun-test/node_modules/pino/lib/transport.js:114:21)
      at normalizeArgs (/Users//***/Workspace/bun-test/node_modules/pino/lib/tools.js:311:15)
      at pino (/Users//***/Workspace/bun-test/node_modules/pino/pino.js:87:27)
      at /Users//***/Workspace/bun-test/server.ts:7:16

Reproduction code:

Create a new bun app, add pino and pino-pretty run the following snippet.

import logger from 'pino';

const logging = logger({
  transport: {
    target: 'pino-pretty',
  },
});

logging.info('hello world');
mcollina commented 1 year ago

Thanks for reporting. We do not have the resources to support Bun users. Please refer to the Bun Discord or Issue Tracker for such questions.

capaj commented 1 year ago

I did a hackfix on my fork here: https://github.com/capaj/pino/commit/8fb80fb207127bc84c9ce5b73dd3899ecedf293f

Tests are passing: image

not sure if it is worth opening a PR. @mcollina would you accept that hackfix into master?

mcollina commented 1 year ago

That's not on my plan. I'm not supporting a runtime that I cannot guarantee via unit tests. When/if I can run the same tests on both... then I'd be more than happy to support them officially.

capaj commented 1 year ago

Fair, thanks for the quick answer. I suspect Bun will be able to fix the Callsite problem quite fast on their side, but if they cannot I might open it for a PR with adding a bun test worklow into https://github.com/pinojs/pino-pretty/blob/master/.github/workflows/ci.yml

mcollina commented 1 year ago

At this point in time, Bun does not run node-tap