Add a cancel token to manually enforce a timeout in Quote Requestor (#176)
* Add a cancel token to manually enforce a timeout in Quote Requestor * Start setTimeout before making requests, add an extra buffer * Run prettier * Add comment to changelog
This commit is contained in:
		| @@ -1,7 +1,7 @@ | ||||
| import { Web3Wrapper } from '@0x/dev-utils'; | ||||
| import { TakerRequestQueryParams, V4RFQFirmQuote, V4RFQIndicativeQuote } from '@0x/quote-server'; | ||||
| import { BigNumber } from '@0x/utils'; | ||||
| import { AxiosInstance } from 'axios'; | ||||
| import { AxiosInstance, CancelToken } from 'axios'; | ||||
|  | ||||
| import { constants } from '../constants'; | ||||
| import { | ||||
| @@ -122,6 +122,7 @@ export async function returnQuoteFromAltMMAsync<ResponseT>( | ||||
|     altRfqtAssetOfferings: AltRfqtMakerAssetOfferings, | ||||
|     takerRequestQueryParams: TakerRequestQueryParams, | ||||
|     axiosInstance: AxiosInstance, | ||||
|     cancelToken: CancelToken, | ||||
| ): Promise<{ data: ResponseT; status: number }> { | ||||
|     const altPair = getAltMarketInfo( | ||||
|         altRfqtAssetOfferings[url], | ||||
| @@ -214,6 +215,7 @@ export async function returnQuoteFromAltMMAsync<ResponseT>( | ||||
|     const response = await axiosInstance.post(`${url}/quotes`, data, { | ||||
|         headers: { Authorization: `Bearer ${apiKey}` }, | ||||
|         timeout: maxResponseTimeMs, | ||||
|         cancelToken, | ||||
|     }); | ||||
|  | ||||
|     if (response.data.status === 'rejected') { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user