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

Doesn't support pino-socket #173

Open
ben-reitz opened this issue Jul 23, 2024 · 0 comments
Open

Doesn't support pino-socket #173

ben-reitz opened this issue Jul 23, 2024 · 0 comments

Comments

@ben-reitz
Copy link

I'm getting the following error when running my app:

"Error: Cannot find module '/var/task/dist/lib/TcpConnection'",
        "Require stack:",
        "- /var/task/dist/pino-socket.js",
        "    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)",
        "    at Module._load (node:internal/modules/cjs/loader:986:27)",
        "    at Module.require (node:internal/modules/cjs/loader:1233:19)",
        "    at require (node:internal/modules/helpers:179:18)",
        "    at Object.<anonymous> (/var/task/node_modules/pino-socket/psock.js:5:30)",
        "    at Module._compile (node:internal/modules/cjs/loader:1358:14)",
        "    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)",
        "    at Module.load (node:internal/modules/cjs/loader:1208:32)",
        "    at Module._load (node:internal/modules/cjs/loader:1024:12)",
        "    at cjsLoader (node:internal/modules/esm/translators:348:17)"

This is because pino-socket has the following line in its main entrypoint:

const tcpConnectionFactory = require(path.join(__dirname, 'lib', 'TcpConnection'))`

which is being transpiled by esbuild to

sf=require(Ie.join(__dirname,"lib","TcpConnection"))

which doesn't work as only a single file pino-socket.js is being created for it.

Is there a way around this?

pino config:
const logger = pino({
    level: 'info',
    transport: {
        pipeline: [
            {
                target: 'pino-syslog',
                options: {
                    appname: process.env.AWS_LAMBDA_FUNCTION_NAME,
                    newline: true,
                },
            },
            {
                target: 'pino-socket',
                options: {
                    host: process.env.LOG_COLLECTOR_HOST,
                    port: process.env.LOG_COLLECTOR_PORT,
                    mode: 'tcp',
                    secure: true,
                },
            },
        ],
    },
});
build:
await esbuild.build({
    entryPoints: [{ in: 'src/server/lambdaHandler.ts', out: 'server' }],
    bundle: true,
    platform: 'node',
    target: 'node20',
    outdir: 'dist',
    minify: true,
    sourcemap: true,
    plugins: [esbuildPluginPino({ transports: ['pino-pretty', 'pino-syslog', 'pino-socket'] })],
    logLevel: 'info',
});
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

1 participant