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: "fn is not a function" while setting up a pino transports since v9.2.1 #2012

Closed
viceice opened this issue Jul 23, 2024 · 8 comments · Fixed by #2014
Closed

Error: "fn is not a function" while setting up a pino transports since v9.2.1 #2012

viceice opened this issue Jul 23, 2024 · 8 comments · Fixed by #2014

Comments

@viceice
Copy link
Contributor

viceice commented Jul 23, 2024

Pino v9.3.0 throws errors

#10 23.21 5e4f8d756c2d9898b115a52167c82923990c1c73 (Node v20.11.1)
#10 23.22 node:events:496
#10 23.22       throw er; // Unhandled 'error' event
#10 23.22       ^
#10 23.22 
#10 23.22 TypeError: fn is not a function
#10 23.22     at /snapshot/dist/pino-worker.js:10
#10 23.22     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
#10 23.22     at async Promise.all (index 0)
#10 23.22     at async module.exports (/snapshot/dist/pino-worker.js:10713:15)
#10 23.22     at async start (/snapshot/dist/thread-stream-worker.js:134:17)
#10 23.22 Emitted 'error' event on ThreadStream instance at:
#10 23.22     at Immediate.<anonymous> (/snapshot/dist/containerbase-cli.js:6481:17)
#10 23.22     at process.processImmediate (node:internal/timers:4

Update PR

Logger init code

The code will be transpiled with esbuild and then packaged with @yao-pkg/pkg

Seems to be related to #1383

@viceice viceice changed the title Error: "fn is not a function" while setting up a pino transports Error: "fn is not a function" while setting up a pino transports since v9.3.1 Jul 23, 2024
@viceice viceice changed the title Error: "fn is not a function" while setting up a pino transports since v9.3.1 Error: "fn is not a function" while setting up a pino transports since v9.3.0 Jul 23, 2024
@mcollina
Copy link
Member

We do our best to avoid regressions. I actually have no clue on why this problem is happening in your codebase. I would recommend you to send a PR to fix this.

@viceice
Copy link
Contributor Author

viceice commented Jul 24, 2024

ok , found it's failing here

const stream = await fn(t.options)

so it seems loadTransportStreamBuilder returns null or undefined 🤔

@viceice
Copy link
Contributor Author

viceice commented Jul 24, 2024

ha, found it #1990

that return is causing to skip these important lines:

// Depending on how the default export is performed, and on how the code is
// transpiled, we may find cases of two nested "default" objects.
// See https://github.com/pinojs/pino/issues/1243#issuecomment-982774762
if (typeof fn === 'object') fn = fn.default
if (typeof fn === 'object') fn = fn.default
if (typeof fn !== 'function') throw Error('exported worker is not a function')

@viceice viceice changed the title Error: "fn is not a function" while setting up a pino transports since v9.3.0 Error: "fn is not a function" while setting up a pino transports since v9.2.1 Jul 24, 2024
@viceice
Copy link
Contributor Author

viceice commented Jul 24, 2024

btw v9.2.1 was not published to npmjs.org

@mcollina
Copy link
Member

mcollina commented Jul 24, 2024

Can you send a PR that fixes this and adds a test?

@viceice
Copy link
Contributor Author

viceice commented Jul 24, 2024

sure :-)

@viceice
Copy link
Contributor Author

viceice commented Jul 24, 2024

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants