Skip to content

Commit

Permalink
feat: add support for aborting requests (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus authored and JustinBeckwith committed Feb 12, 2019
1 parent 17e521f commit 1b47153
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ gaxios.request({url: '/data'}).then(...);
},

// Enables default configuration for retries.
retry: boolean;
retry: boolean,

// Cancelling a request requires the `abort-controller` library.
// See https://github.com/bitinn/node-fetch#request-cancellation-with-abortsignal
signal?: AbortSignal
}
```

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"typescript": "~3.3.0"
},
"dependencies": {
"abort-controller": "^2.0.2",
"extend": "^3.0.2",
"https-proxy-agent": "^2.2.1",
"node-fetch": "^2.2.0"
Expand Down
2 changes: 2 additions & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {AbortSignal} from 'abort-controller';
import {Agent} from 'https';

export class GaxiosError<T = any> extends Error {
Expand Down Expand Up @@ -69,6 +70,7 @@ export interface GaxiosOptions {
validateStatus?: (status: number) => boolean;
retryConfig?: RetryConfig;
retry?: boolean;
signal?: AbortSignal;
size?: number;
}

Expand Down

0 comments on commit 1b47153

Please sign in to comment.