Timeout exception is not caught with cferror
Description
Environment
OS : Windows Server 2019
Java Version : 11.0.15+10
Tomcat Version : Apache Tomcat/9.0.62
Lucee Version : 5.3.9.141
Microsoft JDBC Extension Version : 9.4.1
Attachments
- 06 Jan 2023, 09:12 am
- 06 Jan 2023, 09:12 am
- 06 Jan 2023, 09:12 am
- 07 Dec 2022, 09:48 am
Activity
Pete Freitag 12 May 2023 at 19:35
@Zac Spitzer I am still encountering a case where getTimeoutStackTrace()
is null, and PageContextUtil.remainingTime()
is 0
. In this case if I cfinclude a error page in my onError, even when it is wrapped in a try / catch I cannot catch the exception. Here’s how to reproduce:
Application.cfc:
component {
onError(exception) {
try {
var timeLeft = createObject("java", "lucee.runtime.util.PageContextUtil").remainingTime(getPageContext(), false);
writeOutput("<p>Time Left: #timeLeft#</p>"); //0
writeDump(getPageContext().getTimeoutStackTrace()); //null
cfinclude(template="error-handler.cfm"); //causes the error dump, cannot catch it
} catch (any err) {
writeOutput("Include Error"); //never runs
}
}
}
test.cfm:
<cfsetting requesttimeout="1">
<cfset request.x = 1>
<cfset sleep(500)>
<cfset request.x = 2>
<cfset sleep(500)>
<cfset request.x = 3>
<cfset sleep(500)>
<cfset request.x = 4>
<cfset sleep(500)>
<cfset request.x = 5>
<cfinclude template="empty.cfm">
<cfset request.x = 6>
DONE!
error-handler.cfm:
<h2>Error Handler</h2>
<cfdump var="#exception#">
Run the page a few times, sometimes it will work (when getTimeoutStackTrace is not null) and sometimes it will not not (when it is null).
When it does not the output is:
Time Left: 0
getTimeoutStackTrace() == null
lucee.runtime.exp.RequestTimeoutException (lucee dumps the exception, not error-handler.cfm)
My workaround is going to be to use the timeLeft
variable and not include the error handler, but it would be nice if there were not uncatchable exceptions.
Zac Spitzer 12 May 2023 at 06:48
@Pete Freitag nice digging! @Michael Offner has already changes the onError handler to not timeout https://luceeserver.atlassian.net/browse/LDEV-2756
Pete Freitag 11 May 2023 at 19:59
Some additional info - also triggering this error when not using cferror, but just using a Error Template in the Lucee admin. Here’s how it happens:
Assume I have a query that hits the query timeout, and also the page timeout
Lucee or the DB driver throws a timeout exception
Lucee tries to include the global error template cfm file
When lucee tries to include the global error template it calls which makes a call to
_doInclude
inPageContextImpl
(https://github.com/lucee/Lucee/blob/5.3.10.97/core/src/main/java/lucee/runtime/PageContextImpl.java#L946)The first thing _doInclude() does is call
PageContextUtil.checkRequestTimeout(this);
since we are already over the page timeout this check fails and throws another exception.Thankfully this doesn’t cause an infinite loop, but does cause the dump to be shown.
I can also trigger this dump via a onError if I do a cfinclude to a error.cfm page. So to summarize this error can happen any one of three ways:
When a timeout occurs and cferror tries to include a cfm
When a timeout occurs and onError tries to cfinclude a cfm
When a timeout occurs and the global error handler cfm page (defined in lucee admin) is included
Pothys - MitrahSoft 5 May 2023 at 07:15
I’ve checked this ticket with lucee version 5.3.10.120. When using the above code with cftry, I got the same "The query has timed out" error, Also without using cftry, it throws an "request [/.../LDEV4311/test.cfm (D:\projects\....\....\LDEV4311\test.cfm)] has run into a timeout (timeout: [1] seconds) and has been stopped . The thread started [1724] ms ago" error.
and checked the same with cftry in ACF and it returned "Request exceeded time limit allowed Tag: cfoutput" error. Without using cftry, it throws the error "Error Executing Database Query.[Macromedia][SQLServer JDBC Driver]Execution timeout expired".
@Michael Offner will confirm about this.
Zac Spitzer 5 May 2023 at 07:11Edited
@Pete Freitag playing with this with step debugging, with a pause, cferror works, so as per the previous comments , I think this is indeed caused by https://github.com/lucee/Lucee/commit/788e0625db67b9d2a7b5c6f79cd068fe87bdc57f / https://luceeserver.atlassian.net/browse/LDEV-2332
Details
Assignee
Michael OffnerMichael OffnerReporter
HHPriority
NewNew Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
Affects versions
Details
Details
Assignee
Reporter
Priority
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Hi,
We have the following line in application.cfc in onRequestStart to redirect all uncaught errors to a custom error page:
<cferror type="EXCEPTION" template="error.cfm">
But after updating from Lucee version 5.3.2.77 to Lucee version 5.3.9.141 this does not seem to catch timeout exceptions:
Other errors do go through the error.cfm template.
I asked about this in Timeoute exception is not caught with cferror - dev / support - Lucee Dev. A workaround is using the onError function in application.cfc