nodejs-logging-winston: receiving "connect EHOSTUNREACH 169.254.169.254:80" when following simple README

Environment details

  • OS: Ubuntu 18 LTS
  • Node.js version: 10.16.0
  • npm version: 6.11.3
  • @google-cloud/logging-winston version: 2.0.1
  • winston version: 3.2.1

Steps to reproduce

  1. Use a non-GCP server/environment.
  2. Follow this: https://github.com/googleapis/nodejs-logging-winston/blob/master/samples/quickstart.js

This issue is very similar if not identical to: https://github.com/googleapis/nodejs-logging-bunyan/issues/353

The only resolution I have found so far is to revert back to logging-winston version 0.11.1. Under the environment above, everything then works.

I am seeing this issues whether I set the GOOGLE_APPLICATION_CREDENTIALS env variable or specify the projectId and keyFilename or specify projectId and credentials when creating the LoggingWinston object. So all 3 ways fail on v1.0.0+, but all 3 work on v0.11.1.

I have seen the error appear two different ways, with the first type of error message appearing from following the above steps.

(node:12374) UnhandledPromiseRejectionWarning: FetchError: request to http://169.254.169.254/computeMetadata/v1/instance failed, reason: connect EHOSTUNREACH 169.254.169.254:80
    at ClientRequest.<anonymous> (/home/user/projects/test/node_modules/node-fetch/lib/index.js:1455:11)
    at ClientRequest.emit (events.js:198:13)
    at Socket.socketErrorListener (_http_client.js:392:9)
    at Socket.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:12374) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12374) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Here is an alternative error message that we are seeing using the same environment outlined above, but on a remote server. I do not have reproducible steps for this error message, but this was the first error message we saw before digging deeper. The below error message lead us to the reproducible error message above.

(node:21602) UnhandledPromiseRejectionWarning: Error: Unsuccessful response status code. Request failed with status code 404
    at Gaxios.request (/home/user/test/node_modules/gaxios/build/src/gaxios.js:70:23)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:21602) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21602) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 20 (9 by maintainers)

Most upvoted comments

This is still intermittently happening for me with the following config:

import { LoggingWinston } from "@google-cloud/logging-winston";
import config from "../config";

const gcpTransport = new LoggingWinston({
      projectId: config.serviceAccount.projectId,
      credentials: {
        client_email: config.serviceAccount.clientEmail,
        private_key: config.serviceAccount.privateKey
      },
      logName: `my-api-${config.environment}`,
      resource: {        
        type: "global"
      }
    });

<snipped>

The other annoying thing is, simply importing the transport as above (and never even new’ing one up), is enough for it to cause open handle warnings for @grpc when running under jest

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  Timeout

      at new SubchannelPool (node_modules/@grpc/grpc-js/build/src/subchannel-pool.js:38:13)
      at Object.<anonymous> (node_modules/@grpc/grpc-js/build/src/subchannel-pool.js:99:30)

@michaelreinig Hey, the bug still appears in 5.3.1 but it has a not consistent behaviour.

(node:16476) UnhandledPromiseRejectionWarning: FetchError: request to http://169.254.169.254/computeMetadata/v1/instance failed, reason: connect ENETUNREACH 169.254.169.254:80 at ClientRequest.<anonymous> (D:\BOTfriends\Code\botfriendsLogger\node_modules\node-fetch\lib\index.js:1455:11) at ClientRequest.emit (events.js:182:13) at Socket.socketErrorListener (_http_client.js:399:9) at Socket.emit (events.js:182:13) at emitErrorNT (internal/streams/destroy.js:82:8) at emitErrorAndCloseNT (internal/streams/destroy.js:50:3) at process.internalTickCallback (internal/process/next_tick.js:72:19) (node:16476) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:16476) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@michaelreinig if you update your dependencies, such that @google-cloud/logging is now at 5.3.1, this issue should now be addressed

Please feel free to reopen if you’re continuing to have issues, thank you for your patience.

@bcoe, I can confirm that the issue has been resolved. Thanks again for your help.

@robymes make sure you delete package-lock.json, and rm -rf node_modules, my hunch is that perhaps you have the old dependency in your tree.

If you continue to bump into issues, please go ahead and open a new issue 👍