googleapis / googleapis/google-cloud-node
Accept AbortSignals in async methods
Open
api: firestore
library: nodejs-firestore
priority: p3
type: feature request
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 712
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 99
Description
Methods like `.get()` should accept an AbortSignal to cancel the request.
AbortSignals are becoming more prevalent in platform and library APIs, and it's pretty easy to feed a signal from client-side code, into server requests handlers, and into libraries like firestore, which can send them to the underlying `fetch()` call, to cancel a database call.
Example using tRPC, which provides abort signals:
```ts
const appRouter = router({
getDocs: procedure.query(async ({signal}) => {
return db.collection('documents').get({signal});
}),
});
```
Contributor guide
Assessment
This issue has not been assessed yet.