Skip to content

Missing GrpcStatus in firestore #1064

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

Closed
Thaina opened this issue Oct 15, 2020 · 6 comments · Fixed by #1080
Closed

Missing GrpcStatus in firestore #1064

Thaina opened this issue Oct 15, 2020 · 6 comments · Fixed by #1080
Assignees

Comments

@Thaina
Copy link

Thaina commented Oct 15, 2020

[REQUIRED] Step 2: Describe your environment

  • Operating System version: firebase functions
  • Firebase SDK version: 9.2.0
  • Firebase Product: firestore
  • Node.js version: 12
  • NPM version: 6.14.8

[REQUIRED] Step 3: Describe the problem

I try to check a status code of firestore error without hardcode symbol and turn out GrpcStatus which exist in js firestore package are not exist in admin.firestore for node js

Should there be anything defined for firestore error code?

return admin.firestore().runTransaction((transaction) => {
        // do transaction
	return Promise.resolve();
}).catch((e) => {
	if(e?.code != admin.firestore.GrpcStatus.ALREADY_EXISTS) // error here
		throw e;
})
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@schmidt-sebastian
Copy link
Contributor

@hiranya911
Copy link
Contributor

We already add everything exported by @google-cloud/firestore to the admin.firestore namespace:

> const admin = require('firebase-admin')
> admin.firestore.GrpcStatus
{ '0': 'OK',
  '1': 'CANCELLED',
  '2': 'UNKNOWN',
  '3': 'INVALID_ARGUMENT',
  '4': 'DEADLINE_EXCEEDED',
  '5': 'NOT_FOUND',
  '6': 'ALREADY_EXISTS',
  '7': 'PERMISSION_DENIED',
  '8': 'RESOURCE_EXHAUSTED',
  '9': 'FAILED_PRECONDITION',
  '10': 'ABORTED',
  '11': 'OUT_OF_RANGE',
  '12': 'UNIMPLEMENTED',
  '13': 'INTERNAL',
  '14': 'UNAVAILABLE',
  '15': 'DATA_LOSS',
  '16': 'UNAUTHENTICATED',
  OK: 0,
  CANCELLED: 1,
  UNKNOWN: 2,
  INVALID_ARGUMENT: 3,
  DEADLINE_EXCEEDED: 4,
  NOT_FOUND: 5,
  ALREADY_EXISTS: 6,
  PERMISSION_DENIED: 7,
  RESOURCE_EXHAUSTED: 8,
  FAILED_PRECONDITION: 9,
  ABORTED: 10,
  OUT_OF_RANGE: 11,
  UNIMPLEMENTED: 12,
  INTERNAL: 13,
  UNAVAILABLE: 14,
  DATA_LOSS: 15,
  UNAUTHENTICATED: 16 }

Do you mean we should also add it to our typings?

@hiranya911
Copy link
Contributor

@Thaina when you say error, do you mean a TS compiler error? That's the only error I can see resulting from the above code.

@Thaina
Copy link
Author

Thaina commented Oct 21, 2020

@hiranya911 Yes, sorry for not being clear. It is compiler error

I have searching for enum code in this repo and only found it defined in remote config

https://github.com/firebase/firebase-admin-node/search?q=ALREADY_EXISTS

I think typescript try to find definition in this package directly and it couldn't found GrpcStatus anywhere in admin nodejs

@hiranya911
Copy link
Contributor

We need to re-export the corresponding Firestore enum from our d.ts file. We can get that fixed in a future release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants