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: unable to determine transport target for "@baselime/pino-transport" #2019

Open
jacobsamo opened this issue Jul 31, 2024 · 3 comments
Open

Comments

@jacobsamo
Copy link

For some reason getting the below error, works fine in development but not when built.

⨯ Error: unable to determine transport target for "@baselime/pino-transport"
    at fixTarget (/var/task/node_modules/pino/lib/transport.js:159:13)
    at /var/task/node_modules/pino/lib/transport.js:97:17
    at Array.map (<anonymous>)
    at Function.transport (/var/task/node_modules/pino/lib/transport.js:94:59)
    at /var/task/apps/web/.next/server/app/recipes/preview/[id]/edit/page.js:11:7702
    at 62666 (/var/task/apps/web/.next/server/app/recipes/preview/[id]/edit/page.js:11:7739)
    at t (/var/task/apps/web/.next/server/webpack-runtime.js:1:143)
    at 50073 (/var/task/apps/web/.next/server/app/recipes/preview/[id]/edit/page.js:11:4815)
    at t (/var/task/apps/web/.next/server/webpack-runtime.js:1:143)
    at 3724 (/var/task/apps/web/.next/server/app/recipes/preview/[id]/edit/page.js:11:5969) {
  page: '/recipes/preview/acffe450-7ce2-4a56-be89-1a8c985ce966/edit'
}

My logger code:
https://github.com/jacobsamo/Mixie/blob/mix-170-mvp-bug-fixes/apps/web/src/lib/services/logger/create-logger.ts

import { env } from "env";
import type { TransportTargetOptions } from "pino";
import pino from "pino";

export function createLogger({ dataset }: { dataset: string }) {

  const transport = pino.transport({
    target: "@baselime/pino-transport",
    options: {
      baselimeApiKey: env.BASELIME_KEY,
      dataset,
    },
  });

  return pino(transport);
}

Feel like I could fix this with a webpack config change or similar.

Repo link: https://github.com/jacobsamo/Mixie/tree/mix-170-mvp-bug-fixes

Similar issue to: #1964

@ustad-nordin
Copy link

I have exactly the same problem and made a small project to reproduce the error:
https://github.com/ustad-nordin/axiom-error

I hope someone take a look it and see what the problem is.

@mcollina
Copy link
Member

Considering how Vercel or Netlify works, it's better to load the transport as a stream, and use it in the main process. You'll only have problems in using a different thread in serverless systems.


The problem stems from the fact that threads requires an entrypoint on disk. When bundling, the logic we use to determine which file to load is somewhat broken. There are some example on how to do that for webpack, but none for vite. One would really be helpful.

@filmon-arefayne
Copy link

filmon-arefayne commented Dec 22, 2024

you need to import the package to the file otherwise it may be stripped out in prod build

import "@baselime/pino-transport"

Also in nextjs I solved this by adding the package to the serverComponentsExternalPackages

const nextConfig = {
    output: "standalone",
    experimental: {
        instrumentationHook: process.env.DEPLOYMENT !== "test",
        serverComponentsExternalPackages: [
            "pino",
            "pino-pretty",
            "pino-opentelemetry-transport",
            "kafkajs",
            "@opentelemetry/instrumentation-pino",
            "@opentelemetry/instrumentation-kafkajs",
            "@baselime/pino-transport"
        ],
        ...

Hope it helps

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

4 participants