nodejs-firestore icon indicating copy to clipboard operation
nodejs-firestore copied to clipboard

Accept AbortSignals in async methods

Open justinfagnani opened this issue 7 months ago • 1 comments

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});
  }),
});

justinfagnani avatar May 28 '25 02:05 justinfagnani

Thanks for the suggestion @justinfagnani . I'll let the team know.

ehsannas avatar May 28 '25 17:05 ehsannas