Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add http timeout & more data decode tx resp #1604

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add http timeout & more data decode tx resp
  • Loading branch information
ducphamle2 committed Aug 17, 2024
commit c1e4159047b5f8c94f849b1018a6c8b83d392c51
6 changes: 5 additions & 1 deletion packages/tendermint-rpc/src/rpcclients/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ export async function http(
headers: Record<string, string> | undefined,
request?: any,
): Promise<any> {
const timeout = Number(
process.env.HTTP_TIMEOUT || 30000,
);
if (typeof fetch === "function" && !isExperimental(fetch)) {
const settings = {
method: method,
signal: timeout,
body: request ? JSON.stringify(request) : undefined,
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand All @@ -55,7 +59,7 @@ export async function http(
.then((res: any) => res.json());
} else {
return axios
.request({ url: url, method: method, data: request, headers: headers })
.request({ url: url, method: method, data: request, headers: headers, timeout })
.then((res) => res.data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ interface RpcTxResponse {

function decodeTxResponse(data: RpcTxResponse): responses.TxResponse {
return {
...data,
tx: fromBase64(assertNotEmpty(data.tx)),
result: decodeTxData(assertObject(data.tx_result)),
height: apiToSmallInt(assertNotEmpty(data.height)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ interface RpcTxResponse {

function decodeTxResponse(data: RpcTxResponse): responses.TxResponse {
return {
...data,
tx: fromBase64(assertNotEmpty(data.tx)),
result: decodeTxData(assertObject(data.tx_result)),
height: apiToSmallInt(assertNotEmpty(data.height)),
Expand Down