googleapis / nodejs-logging-winston

Node.js client integration between Stackdriver Logging and Winston.
https://cloud.google.com/logging/
Apache License 2.0
105 stars 50 forks source link

Possible replication of bug from nodejs-logging-bunyan #795

Closed yuku closed 10 months ago

yuku commented 1 year ago

It appears that a bug within the nodejs-logging-winston repository mirrors a previously resolved issue in the nodejs-logging-bunyan repository, specifically issue https://github.com/googleapis/nodejs-logging-bunyan/issues/626 - Duplicate HTTP request entries when running in Cloud Run.

The root of this problem seems to lie within this block of code in nodejs-logging-winston:

https://github.com/googleapis/nodejs-logging-winston/blob/9b8657aa436787591c03717e1111117cda6687ee/src/middleware/express.ts#L83

This block is identical to the code previously found in nodejs-logging-bunyan before the bug was fixed with pull request https://github.com/googleapis/nodejs-logging-bunyan/pull/658 (link):

  if (env !== GCPEnv.APP_ENGINE && env !== GCPEnv.CLOUD_FUNCTIONS) {

Following the implementation of the pull request in nodejs-logging-bunyan, the code was amended to (link):

  if (
    env !== GCPEnv.APP_ENGINE &&
    env !== GCPEnv.CLOUD_FUNCTIONS &&
    (env !== GCPEnv.CLOUD_RUN || !options.skipParentEntryForCloudRun)
  ) {

It seems plausible that applying a similar fix in nodejs-logging-winston could resolve this issue.