Hello Lucee Devs,
Our REST endpoints will not return data the first few times when using cfoutput, while using cfreturn does return data every time consistently.
It’s a simple API endpoint, mapped, has correct handlers in IIS, etc.
For example:
<cfcomponent restpath="/api/v1/test" rest="true" httpmethod="GET">
<cffunction name="test" access="remote" returntype="any" httpmethod="GET" produces="text/plain" returnformat="json">
<cfoutput>test</cfoutput>
<!--- with or without additional return directive, still inconsistent --->
<cfreturn>
</cffunction>
</cfcomponent>
…will return blank lines for the first 1-3 times, but after hitting it 2-4 times in succession will return the output. If I wait 30 seconds or so and try again, we’re back to blank lines until it’s “warmed up”.
Whereas a returns 100% of the time.
I’ve tested every combination of headers, caching, etc, removed all complexity (no DB, no queries, just cfoutput a string) and determined the issue to be with cfoutput. I’ve tried setting “inspect templates” = “never” in case it was a recompile issue, but that does NOT fix it. I’ve tried every combination of headers, cfsettings, processing directives, etc. It is somehow caused by the combination of a REST endpoint and cfoutput.
I’ve checked the logs and debugging, and the only references I’m seeing (with EVERYTHING at trace) is in scope.log with:
DEBUG","Thread-54734","05/30/2023","07:35:06","scope-context","use existing session scope for myRestApplication/aeec96a6-f33b-4577-8090-9c28b2b20b12 from storage memory"
"INFO","Thread-54734","05/30/2023","07:35:06","scope-context","remove memory based session scope for myRestApplication/aeec96a6-f33b-4577-8090-9c28b2b20b12"
I tried setting scope from ‘memory’ to cache, issue still persists.
The catch, or “why not just use cfreturn as it’s designed?”: CFReturn will always QUOTE the response, whereas cfoutput provides raw response without quotes. This is vital as we have 3rd party APIs which we cannot update. (This is a migration effort from ACF to Lucee and we need 100% parity on this).
Is there something I’m overlooking? Is this a lucee bug, or known issue? Has this perhaps been fixed in a newer version? Is there some combination of settings or code that will make cfoutput in a REST endpoint consistent, or alternatively to remove the quotes from a cfretrun?
Any insights or thoughts appreciated!
OS : Windows Server 2019, IIS 10
Java Version : Java 11.0.11 AdoptOpenJDK 64bit, and JRE 8 build 301 (8.0.3010.9)
Tomcat Version : Apache Tomcat 9.0.46
Lucee Version : 5.3.9.129-RC