File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,12 @@ export * from './src/api/transaction/types';
2323export * from './src/api/user/types' ;
2424export * from './src/credentials' ;
2525export type { SdkError } from './src/errors' ;
26- export { ApiError , MaxRelationSizeError , TransactionError } from './src/errors' ;
26+ export {
27+ AbortError ,
28+ ApiError ,
29+ MaxRelationSizeError ,
30+ TransactionError ,
31+ } from './src/errors' ;
2732export * from './src/proto/generated/message' ;
2833export * from './src/proto/generated/schema' ;
2934export * from './src/results/resultTable' ;
Original file line number Diff line number Diff line change @@ -82,7 +82,20 @@ export class MaxRelationSizeError extends Error {
8282 }
8383}
8484
85+ export class AbortError extends Error {
86+ constructor ( message ?: string ) {
87+ super ( message ) ;
88+
89+ this . name = 'AbortError' ;
90+ }
91+
92+ toString ( ) {
93+ return this . message ?? this . name ;
94+ }
95+ }
96+
8597export type SdkError =
98+ | AbortError
8699 | ApiError
87100 | TransactionError
88101 | MaxRelationSizeError
Original file line number Diff line number Diff line change 1616
1717import { stringify } from 'query-string' ;
1818
19- import { makeError } from './errors' ;
19+ import { AbortError , makeError } from './errors' ;
2020import { getFetch , Response } from './fetch.node' ;
2121import { ApiResponse , VERSION } from './types' ;
2222
@@ -37,6 +37,7 @@ export type PollOptions = {
3737 overheadRate ?: number ;
3838 maxInterval ?: number ;
3939 timeout ?: number ;
40+ signal ?: AbortSignal ;
4041} ;
4142
4243export type PollingResult < T > = {
@@ -173,6 +174,11 @@ export async function pollWithOverhead<T = void>(
173174 return new Promise < T > ( ( resolve , reject ) => {
174175 const poll = ( delay : number ) => {
175176 setTimeout ( async ( ) => {
177+ if ( options ?. signal ?. aborted ) {
178+ reject ( new AbortError ( ) ) ;
179+ return ;
180+ }
181+
176182 try {
177183 const pollingResult = await callback ( ) ;
178184 if ( pollingResult . done && pollingResult . result ) {
You can’t perform that action at this time.
0 commit comments