nodejs-firestore
nodejs-firestore copied to clipboard
Accept AbortSignals in async methods
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:
const appRouter = router({
getDocs: procedure.query(async ({signal}) => {
return db.collection('documents').get({signal});
}),
});
Thanks for the suggestion @justinfagnani . I'll let the team know.