Hi, all. I have a question about how timeout setting works on aggregates.I have a aggregate in a server action to fetch some data to use them later.I was trying to test error handling on the aggregate's time out, so I set "timeout" property of the aggregate to "1".
However, the aggregate did not timed out when I called the server action, even though the aggregate took much more than 1 second.
What could I be missing to make it work?
Thanks in advance.
Simulating a timeout using an aggregate query is a bit challenging, as it's typically a SELECT statement, and the database may cache the results if the query parameters don't change. As a result, repeated executions may return too quickly to trigger a timeout.
However, you can easily simulate a timeout using an advanced query. For example, set the query to:
WAITFOR DELAY '00:00:05';
You can define the output as any structure . Then, set the query timeout to 1 second.
This will force the database to delay for 5 seconds, exceeding the 1 second timeout limit, and as a result, an exception will be thrown due to the timeout.
Hi @Shinichiro Endo
Setting the Aggregate timeout = 1 does not force the query to stop after 1 second.
In Reactive Web, when the aggregate is inside a Server Action, the timeout mostly controls how long the caller waits for the response, not necessarily whether the SQL execution itself gets aborted immediately. So even if your Aggregate takes more than 1 second, it may still complete successfully unless the request timeout / SQL timeout is hit.
Usually if you are trying to “test error handling”, use Server Request Timeout instead of Aggregate timeout. Because in real Reactive apps, users mostly experience:
rather than a clean aggregate timeout.
@Mandar Deshpande ,
i noticed you are active the last couple of weeks replying to old posts. It is likely that the original poster is no longer interested / waiting for an answer. Be mindful of that.
As to the content of your reply : your statement is incorrect :
And you are confounding server action timeout with aggregate timeout in this statement
In Reactive Web, when the aggregate is inside a Server Action, the timeout mostly controls how long the caller waits for the response, not necessarily whether the SQL execution itself gets aborted immediately. So even if your Aggregate takes more than 1 second, it may still complete successfully
Setting a timeout on an aggregate gets passed along into the dbms, and the query stops executing when reached. You will then get a database error saying "Error executing query. Execution Timeout Expired. "
On the other hand, if the timeout on the aggregate doesn't hit, but the timeout on the server action where the aggregate is used, then the error will be "The connection has timed out "
Dorine
Hi @Shinichiro Endo,As mentioned before, a 1 second timeout for an aggregate is way too short. Without knowing your specific scenario, I’d suggest bumping it up to 10 seconds, or even clearing it so it uses the default timeout
Taking a closer look at your question, I see now that you're focusing on error handling for timeouts.
I put together a quick demo to show you how I handle it. Let me know if this hits the mark.
@Rui Mendes ,
your second read of the question already moved you forward a little.
Now read again, OP is asking specifically about aggregate timeouts, not server action timeouts. There is no aggregate in sight on your demo oml.
True, @Dorine Boudry , good catch. The demo shows how to trigger timeouts in actions, not specifically for aggregates.
Got it — thanks for the clarification. That makes sense.
I will re-test with a slower query to validate the Aggregate timeout behavior more accurately.