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

Unhandled 'error' event for the initial example #33

Open
sbcgua opened this issue May 30, 2023 · 3 comments
Open

Unhandled 'error' event for the initial example #33

sbcgua opened this issue May 30, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@sbcgua
Copy link

sbcgua commented May 30, 2023

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
@metcoder95
Copy link
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 😞

@sbcgua
Copy link
Author

sbcgua commented Jun 21, 2023

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"
  }
}

@metcoder95
Copy link
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

@metcoder95 metcoder95 added the bug Something isn't working label Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants