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

Contract client timeouts should be configurable #1061

Open
Ifropc opened this issue Sep 23, 2024 · 11 comments
Open

Contract client timeouts should be configurable #1061

Ifropc opened this issue Sep 23, 2024 · 11 comments

Comments

@Ifropc
Copy link

Ifropc commented Sep 23, 2024

As per title. Right now I can't change axios timeouts and It throws exception on slow network. Currently, there's nothing you can do about it 😔 . Same contract code execution is working using cli, but throws axios timeout error with the SDK. Strangely, timeout seem to be very low (<1s) because invocation fails almost immediately.

@Dprof-in-tech
Copy link

Dprof-in-tech commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello, i am Dprof-in-tech, an experienced Full Stack Blockchain Developer and I am excited to contribute my skills to this project in this ODHACK 8. With a strong background in Next.js, TypeScript, JavaScript, React, Node.js, Rust and Cairo, I've honed my technical skills across the blockchain development landscape.

My journey with OnlyDust began at Edition 2, and I've since made 34 contributions across 11 projects. This extensive experience on the platform has allowed me to develop a keen understanding of delivering high-quality solutions under tight deadlines. I bring a unique blend of technical prowess and user-centric design to every project, whether I'm crafting immersive 3D experiences or developing innovative smart contracts.

My track record demonstrates my ability to adapt quickly and contribute effectively to diverse challenges. I'm confident in my capacity to tackle new problems and drive innovation in the blockchain space. As we begin ODHACK 8, I'm eager to leverage my hackathon experience and technical skills to push the boundaries of what's possible in blockchain development.

Below is a link to my OnlyDust public profile.
https://app.onlydust.com/u/Dprof-in-tech

How I plan on tackling this issue

Approach for Making Contract Client Timeouts Configurable:

  1. Review Current Axios Implementation
    I will begin by reviewing the existing codebase, particularly where Axios is used to make contract client requests. This could involve reviewing the SDK initialization code and any utility files that handle network requests.
    The goal here is to identify how the current timeout setting is applied within Axios and where modifications can be made to allow this timeout to be configurable.

  2. Add Configurable Timeout Option
    I will introduce an optional configuration parameter for the contract client SDK that allows users to set a custom timeout value for Axios requests.
    Specifically, I will:
    Modify the SDK initialization or the method where Axios is configured to accept a timeout parameter.
    This timeout parameter will allow users to set a custom timeout (in milliseconds) when initializing the SDK. If the timeout is not provided, it will default to a reasonable value (e.g., 30 seconds).
    The axios instance will then use this value when making API calls, giving developers more control over how long the client should wait for a response, especially on slow networks.

  3. Modify Axios Configuration
    I will modify the Axios configuration within the SDK where network requests are made. This will involve:
    Passing the custom timeout value to the Axios instance using its timeout configuration option.
    If no timeout is specified by the user, I will ensure that the default value is used.
    I will also review the contract execution logic to make sure that the configurable timeout is applied consistently across different API calls (e.g., contract invocation, data fetching).

  4. Error Handling Improvements
    I will improve the error handling mechanism for timeout errors:
    In cases where a request times out due to slow network conditions, a more informative error message will be thrown to inform the user that the operation failed due to a timeout.
    I will also include suggestions in the error message on how users can increase the timeout value to prevent the error in future requests.
    These error messages will be user-friendly and give clear instructions on how to adjust the timeout configuration.

  5. Test the Timeout Configuration
    I will write tests to verify the behavior of the configurable timeout:
    I will simulate slow network conditions and verify that the timeout triggers as expected when using the default and custom values.
    Tests will cover multiple scenarios, such as:
    No timeout specified (should use default value).
    Custom timeout set by the user (ensures requests wait as long as the custom value allows).
    Network delays that cause requests to time out.
    I will also include tests to confirm that requests succeed if network delays do not exceed the configured timeout.

  6. Update Documentation
    I will update the relevant documentation to include information on how to configure the contract client’s timeout settings.
    This will involve:
    Adding a section in the SDK’s documentation that explains how to pass a custom timeout value during initialization.
    Describing the default timeout behavior and how developers can configure it for different network environments.

  7. Submit the Changes for Review
    After implementing the timeout configuration feature and completing testing:
    I will submit a pull request with the changes.
    This PR will include:
    Modifications to the Axios configuration in the SDK.
    New test cases that validate the custom timeout behavior.
    Documentation updates detailing how to configure the timeout.
    I will also request feedback from the project maintainers and address any comments or revisions.

  8. Estimated Timeline
    Start Date: Immediately upon assignment.
    Estimated Completion Date: 3 days from the start date.

@raizo07
Copy link

raizo07 commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello I'll like to be assigned to work on this.

I'm a software Dev with over four years experience and have worked on a couple of projects here. Here's a link to my profile https://app.onlydust.com/u/raizo07

@Ugo-X
Copy link

Ugo-X commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Full Stack blockchain Developer with expertise in Next.js, Nest.js, TypeScript, JavaScript, React, Node.js, Three.js, Solidity and rust. My journey with OnlyDust hackathons began at Edition 1, and I've since made 69 contributions across 14 projects. With my extensive experience on the OnlyDust platform (profile: https://app.onlydust.com/u/Ugo-X), I've honed my skills in delivering quality solutions under pressure.

I bring a unique blend of technical proficiency and user-focused design to every project, whether it's crafting immersive 3D experiences or developing smart contracts. My track record shows I can adapt quickly and contribute effectively to diverse challenges.

As we surf through Edition 8, I'm excited to leverage my skills and hackathon experience to push the boundaries of blockchain development. I'm confident in my ability to tackle new challenges and drive innovation in this space.

How I plan on tackling this issue

I will implement configurable timeouts for contract client methods. The approach is:

  • I will modify the contract client configuration to accept a timeout parameter when initializing the client.

  • I will update the axios request settings within the client to utilize this timeout parameter, allowing users to specify a custom timeout duration.

  • I will ensure backward compatibility by setting a reasonable default timeout (e.g., 15 seconds).

  • I will test the new configuration under different network conditions to ensure it performs well and does not throw exceptions unnecessarily

@MullerTheScientist
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a full-stack developer with experience in QA testing and languages like Python, Cairo, Solidity, React, and JavaScript.

How I plan on tackling this issue

i will Define Configuration Options
Determine the timeout configuration options:
Connection timeout
Read timeout
Write timeout
Global timeout
Add Configuration Parameters
Update the contract client constructor or initialization method to accept timeout configuration options
Add parameters for each timeout option

@martinvibes
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

hello i am a frontend dev and blockchain developer
please can i work on this issue :) and would love to be a contributor

How I plan on tackling this issue

this issue is easy to tackle please kindly assign

@petersdt
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I specialize in software development with a focus on JavaScript and frameworks like React. I have experience configuring Axios for Api requests optimizing performance. kindly assign me ETA < 72hrs

How I plan on tackling this issue

Locate the Axios Instance: I will find where the Axios instance is created in the SDK.

Increase Timeout Value: I will modify the Axios configuration to increase the timeout, for example, setting it to 5000ms.

Implement Error Handling: I will add interceptors to catch and log timeout errors gracefully.

Test the Configuration: I will run the SDK under slow network conditions to ensure the new timeout settings work as intended.

Compare with CLI: I will check the Axios settings against the CLI configuration to ensure consistency.

Document Changes: Finally, I will document any modifications made to the timeout settings for future reference.

@ShantelPeters
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

i am a frontend developer with 2 years experience. i would love to make my first contribution to this project

How I plan on tackling this issue

To approach this problem i will update the Axios instance configuration in the SDK to allow for customizable timeout settings. Provide a way for users to set the timeout value, ensuring it can accommodate slower network conditions and prevent premature timeout exceptions during contract code execution.

@janewang janewang removed the ODHack8 label Sep 26, 2024
@janewang
Copy link

Removing ODHack8 as we are moving away from Axios

@janewang
Copy link

@Dprof-in-tech This issue is no longer relevant as we are removing axios as a dependency on the js-stellar-sdk. Due to this, please note that this issue is not longer in scope for ODHack8. Apologies for this change

@Shaptic
Copy link
Contributor

Shaptic commented Sep 27, 2024

@janewang that's not entirely true: axios will still be a dependency, there will just be the option to install with an axios replacement. We may move away from axios entirely in the future, but that isn't the state of the union today.

@Dprof-in-tech
Copy link

@Dprof-in-tech This issue is no longer relevant as we are removing axios as a dependency on the js-stellar-sdk. Due to this, please note that this issue is not longer in scope for ODHack8. Apologies for this change

thtas okay then. If i may ask, is there any other issue within the 0dhack8 scope i could work on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo (Ready for Dev)
Development

No branches or pull requests

10 participants