google-cloud-node
google-cloud-node copied to clipboard
`FetchError: request to https://oauth2.googleapis.com/token failed`
Environment details
- OS: macOS
- Node.js version: Node.js v17.5.0
- npm version: 8.4.1
-
@google-cloud/compute
version: "^3.3.0"
Steps to reproduce
- Do some combination of create/list/delete compute engine instances for a few minutes. Note: Seems more common when the event loop is blocked working for a few minutes.
I get this error occasionally:
/x/node_modules/node-fetch/lib/index.js:1491
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
^
FetchError: request to https://oauth2.googleapis.com/token failed, reason: getaddrinfo ENOTFOUND oauth2.googleapis.com
at ClientRequest.<anonymous> (/x/node_modules/node-fetch/lib/index.js:1491:11)
at ClientRequest.emit (node:events:526:28)
at TLSSocket.socketErrorListener (node:_http_client:442:9)
at TLSSocket.emit (node:events:526:28)
at emitErrorNT (node:internal/streams/destroy:164:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
type: 'system',
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
config: {
method: 'POST',
url: 'https://oauth2.googleapis.com/token',
data: 'refresh_token=x&client_id=x&client_secret=x&grant_type=refresh_token',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'google-api-nodejs-client/8.0.2',
'x-goog-api-client': 'gl-node/17.5.0 auth/8.0.2',
Accept: 'application/json'
},
paramsSerializer: [Function: paramsSerializer],
body: 'refresh_token=x&client_id=x&client_secret=x&grant_type=refresh_token',
validateStatus: [Function: validateStatus],
responseType: 'json'
}
}
- I am running Node.js on a Mac.
- I think it is using gcloud/ADC (Application Default Credentials) as I am not setting a
GOOGLE_APPLICATION_CREDENTIALS
env var. - I also get an ECONNRESET error.
- I have tried wrapping all the async Google code in a try/catch, but this errror is not caught and crashes the Node process. The stack traces do not link back to my application code so I am not sure what triggers it.
I am assuming that the Google Cloud library is doing a poll to refresh this token, but if that fails it will also crash the process?