12 Sep 2023 09:03 AM - last edited on 12 Sep 2023 10:13 AM by Ana_Kuzmenchuk
I have a code like this:
export default async function ({ execution_id }) {
// get and verify event context
console.log("Get and verify event context")
var exec_req = await fetch(`/platform/automation/v1/executions/${execution_id}`)
var execution_obj = await exec_req.json()
if (!'event' in execution_obj.params) {
return { problem: null }
}
var event = execution_obj.params.event
// get problem details
console.log("Loading Problem details...")
var problem_request = { problemId: event['event.id'] }
var problem = await problemsClient.getProblem(problem_request)
return { problem }
And the error is:
An error occurred: Action result is too large. Do not use results for passing bulk data.
In the last line, return
What other ways are there to return a large result in wokflows? I am trying to get an answer in this documentation https://developer.dynatrace.com/develop/workflows/
Many thanks
12 Sep 2023 09:05 AM
I forgot to mention, I need to return the information for use in another workflow task.
12 Sep 2023 10:07 PM
The "Action result is too large" error typically occurs when you're trying to return a very large object or a result that exceeds the allowed size limit for the response. To resolve this issue, you can take the following steps:
1. Check the Size of `problem`: Since the error message mentions "Action result," it's likely that the `problem` object being returned is too large. You should inspect the size of the `problem` object and its nested properties.
2. Reduce the Size of `problem`: If the `problem` object is indeed too large, consider whether you can reduce its size by excluding unnecessary data. You might only need specific properties of the problem rather than the entire object.
3. Pagination: If the `problem` object contains a list of items or records (e.g., a list of comments or attachments), consider implementing pagination to fetch and return smaller subsets of data at a time.
4. Compress Data: If the data cannot be reduced further, you can consider compressing it before sending it as a response. JavaScript provides libraries and functions for data compression, such as `zlib` or `pako`, depending on your environment.
Here's an example of how you might apply compression to the response:
```javascript
import zlib from 'zlib';
export default async function ({ execution_id }) {
try {
// ... (fetching and processing data)
// Compress the problem data
const compressedProblem = zlib.deflateSync(JSON.stringify(problem));
return { compressedProblem };
} catch (error) {
console.error("An error occurred:", error);
return { compressedProblem: null };
}
}
```
5. Consider Streamlining: If you're working with extremely large datasets, consider a different approach that doesn't involve returning the entire dataset in a single response. For instance, you might implement streaming or provide options for users to request specific parts of the data.
Remember to adjust the client-side code that consumes this function to handle the compressed data appropriately.