Skip to content

Unhandled 'error' event for the initial example #33

Description

@sbcgua

Describe the bug
The (slightly modified) example from the docs results in Unhandled 'error' event.
Although the logs were successfully sent (!).

To Reproduce

import fs from 'node:fs';
const CRED_FILE_PATH = './path-to-credentials.json';
const creds = JSON.parse(fs.readFileSync(CRED_FILE_PATH, 'utf-8'));

import pino from 'pino';
const logger = pino({
    transport: {
        target: 'cloud-pine',
        options: {
            logName: 'my_cloud-pine',
            cloudLoggingOptions: {
                googleCloudOptions: {
                    projectId:   creds.project_id,
                    credentials: creds,
                },     
            }
        }
    }
});

logger.info('Hello from pino');
logger.error({ andSomedata: 1 }, 'Pino Error');

Expected behavior
No errors, graceful exit

Screenshots

$node pino.js
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: end() took too long (10s)
    at end (C:\Users\...\test-google-logs\node_modules\thread-stream\index.js:406:15)
    at ThreadStream.end (C:\Users\...\test-google-logs\node_modules\thread-stream\index.js:258:5)
    at autoEnd (C:\Users\...\test-google-logs\node_modules\pino\lib\transport.js:75:10)
    at process.wrap (C:\Users\...\test-google-logs\node_modules\on-exit-leak-free\index.js:10:7)
    at Object.onceWrapper (node:events:628:26)
    at process.emit (node:events:513:28)
Emitted 'error' event on ThreadStream instance at:
    at destroy (C:\Users\...\test-google-logs\node_modules\thread-stream\index.js:349:12)
    at end (C:\Users\...\test-google-logs\node_modules\thread-stream\index.js:415:5)
    at ThreadStream.end (C:\Users\...\test-google-logs\node_modules\thread-stream\index.js:258:5)
    [... lines matching original stack trace ...]
    at process.emit (node:events:513:28)

Desktop (please complete the following information):

  • OS: Windows 10
  • Nodejs: v18.16.0

Activity

  1. metcoder95 commented on May 30, 2023

    @metcoder95
    Owner

    Hi! Thanks for the report! 🙂
    I've tried to reproduce the error but I only could do it if I try to connect to GCP, as I lack credentials. Most likely something similar might happened.

    Could you reproduce it or is there any other stack trace or error message? Sadly it is not rich enough to reproduce it 😞

  2. sbcgua commented on Jun 21, 2023

    @sbcgua
    Author

    Hi, sorry for late response :(

    The log entry is delivered so it is not an issue with the credentials.
    image

    And I retried this code which I posted - it actually fails and with the stack I posted. Not sure how to extract additional information.

    Here is also the package.json just in case (though it is a bit messy with other experiments)

    {
      "name": "test-google-logs",
      "version": "1.0.0",
      "description": "",
      "type": "module",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC",
      "dependencies": {
        "@google-cloud/logging": "^9.9.0",
        "@google-cloud/logging-bunyan": "^4.2.2",
        "bunyan": "^1.8.15",
        "cloud-pine": "^2.0.0",
        "dotenv": "^16.0.3",
        "pino": "^7.9.2"
      }
    }
    
  3. metcoder95 commented on Jun 21, 2023

    @metcoder95
    Owner

    Hey! No worries at all!

    Then, here I'm guessing the Google logging implementation is taking longer to close the other end of the stream, causing the transport to time out.

    Let me take a look deeply into it soon based on what you are sharing! Thanks for the information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions