googleapis / googleapis/google-cloud-node

Permanent redirect to from instance to instance/

Open
#7,799 5 comments 0 reactions 0 assignees View on GitHub
library: google-cloud-node-core priority: p3 type: feature request
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

In a firebase function, which is just a wrapper around a Google Cloud Function, whenever the firestore code is fetching the project details, which triggers an `isAvailable` call. I see that there's a permanent redirect (301) from either:
`http://169.254.169.254/computeMetadata/v1/instance -> http://169.254.169.254/computeMetadata/v1/instance/`
`http://metadata.google.internal./computeMetadata/v1/instance -> http://metadata.google.internal./computeMetadata/v1/instance/`

These calls are rather slow and have high variance, taking between 20 and 200ms (I have seen times larger than a couple of seconds too).

I think that the code in the `metadataAccessor` (https://github.com/googleapis/gcp-metadata/blob/3f1eadacaa36f04aa1f105050031f6c158330576/src/index.ts#L67), should be changed so that when there's no property the url ends with a trailing slash, at least for the `instance` type.

See the traces below
Screen Shot 2020-06-05 at 10 57 29 AM

### Environment details

- OS: Firebase Functions
- Node.js version: 10.18.1
- npm version: 6.14.4
- `gcp-metadata` version: 3.5.0

#### Steps to reproduce

1. Make a firestore request in a Firebase Function
2. Check the traces of the http request

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.