API timeout & errors
JDoodle’s API has timeout limits for execution. Different languages have varying timeout durations depending on the complexity and typical execution time.
Why does my users’ code timeout?
The most likely reasons for timeout are:
- You are using the REST API but your user’s code expects user input. In this case, you need to use interactive mode or submit their input with the REST call.
- Your user wrote an infinite loop
- Your users are executing very complex or resource-intensive code. Contact our support team if you need to upgrade execution capacity.
API timeout for different languages
Here’s a breakdown of the timeout settings and what to do in case of a timeout error: API Type| | Language | Timeout Duration | |--------|----------------| | Python3 | 60 seconds | | All | 120 seconds |
Response
If your user’s code times out, JDoodle will return a 200 - OK statusCode but the output will be as follows:
{
"output": "JDoodle - Timeout. If your program reads input, please enter the inputs in the STDIN box above or try to enable the 'Interactive' mode option above. Please check your program does not contain an infinite loop. Contact JDoodle support at hello@jdoodle.com for more information.",
"error": None,
"compilationStatus": None,
"cpuTime": None,
"isExecutionSuccess": 1,
"statusCode": 200,
"projectKey": None,
"memory": None,
"isCompiled": 0
}
What to do in case of a timeout?
- Provide an error message to your user to explain the reason their code isn’t running.
- Make sure the user’s code is efficient and free of unnecessary loops. split the code into smaller parts for execution if possible.
- Use WebSocket API for longer execution times if REST API limits are reached.
- Implement retry logic with exponential backoff to handle temporary issues.
- Track execution time and performance using logs or analytics to identify patterns causing timeouts.
API error handling
Error| | Description | Action steps | |-----------|------------| | --- 500 or 410: Server Error | These errors indicate an internal issue with | | JDoodle’s servers. | * | | Retry the request after a short delay. * Implement a retry mechanism with exponential backoff to handle these errors more efficiently. * If they persist, then contact our support team. 429: Daily Limit Reached | This error indicates that you have reached your daily request limit for the | | API. | * | | This error occurs due to incorrect parameters or missing information. | * | | This error occurs when the authentication credentials are invalid or expired. | * |
What to do when you get an error?
Here are the steps to follow if you encounter an error:
- Review the error message and status code returned by the API to understand the nature of the problem.
- Please refer to the API documentation to understand the error code and see if there are any suggested solutions or troubleshooting steps.
- Ensure all required parameters are included and correctly formatted in your API request. Common issues include missing parameters, incorrect parameter values, or syntax errors.
- Ensure that your Client ID and Client Secret are correct and that your authentication token is valid and not expired.
- If you encounter a 429 error (Daily Limit Reached), check your API usage to see if you have exceeded your daily credit limit. If you frequently reach the limit, you can also upgrade your subscription.
- Log detailed information about the error, including the request payload and the response received from the API. This can help you diagnose the issue and provide context if you need to contact support.
- Try retrying the request after a short delay for transient errors, such as a 500 or 410 server error. Implementing a retry mechanism with exponential backoff can be beneficial.
Still facing issues?
If you’re experiencing ongoing issues or your users’ code is regularly timing out due to complexity, please reach out to JDoodle’s support team.