OnApplicationStart not always called

Description

Sometimes, OnApplicationStart is not called, resulting in an uninitialized application scope containing just the application name and nothing else.

I believe this is related to the application timing out before the session.
What appears to happen is the application times out and calls onApplicationEnd() and provides the application scope to onApplicationEnd(). All good so far.

Then the session expires and onSessionEnd() is called and it has the session scope passed in correctly. The real application scope is already gone though and Lucee appears to create a new application scope to pass into onSessionEnd().

Then on the next request to the site, the uninitialized application scope exists so onApplicationStart() isn't run and everything is totally broken.

I have captured this in the included log file.
The situation unfolds like this:

Setup: Go to site where application timeout is AT LEAST one minute less than session timeout (it seems Lucee only cleans up sessions and applications once per minute). Then wait.
Log Line 2: Application times out - All the stuff I put in application scope present
Log line 3: Session times out - New uninitialized application scope provided
Log line 4: Session times out continued - All session variables provided correctly
In between now and next log line: Site is broken - application scope empty other than applicationName. My code fails in onRequestStart() because its looking for application variables.
Log line 5: Uninitialized application times out
Afterward - Everything good, new application will be created and initialized properly on next request

This issue has happened for a while in Lucee. Not sure when I first noticed it as I just thought it was a bug in my code.

Environment

Windows 7 IIS 7

Attachments

2
  • 18 Jan 2017, 02:54 am
  • 16 Jan 2017, 12:13 am

Activity

Show:

Pothys - MitrahSoft 1 July 2021 at 14:28

This issue was fixed from 5.2.9.13-SNAPSHOT onwards. So I deployed this ticket with the fixed version.
https://github.com/lucee/Lucee/commit/f68af37180079ca281ed359d07c7ab531ace0f21

Michael Offner 30 January 2017 at 08:37

Estimate: 7h

Pothys - MitrahSoft 18 January 2017 at 06:03

Hi & ,

I've confirmed that the issue( OnApplicationEnd has been called twice ) happening on latest version of lucee. But i'm not sure, whether it is an actual issue or not. Because if application timeout is lesser than session timeout, onApplicationEnd has been called before session timeout. So If any application scoped variable used in onSessionEnd causes the error. But as per the Application.cfc, onSessionEnd should have the session cleanup code. There shouldn't be the code related to application scopes.

, Please take a look on my first comment & confirm that this is an issue or not.

CK 18 January 2017 at 03:09

Also, I think your posted log file shows the issue too. There are 2 onApplicationEnds and only one onApplicationStart.

CK 18 January 2017 at 03:01

Here is my sample code. Not sure if some setting affects it so I exported my settings into the application.cfc using the admin.
It consistently shows the problem for me.

I included a sample log file of what I am getting.
It shows the process: Go to site, wait for application AND session to expire, immediately after session expires reload site - no onApplicationStart

If session expires before application, I don't think it will show the bug. If you go back to site after application expires but before session expires, it won't show the bug.

Unresolved

Details

Assignee

Reporter

Priority

Fix versions

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

Affects versions

Created 16 January 2017 at 00:31
Updated 1 July 2021 at 14:29

Flag notifications