Skip to content

fix(cli): guard onSessionEnd via applicationScope.wo (#3379) - #3394

Merged
bpamiri merged 2 commits into
developfrom
cursor/onsessionend-scope-guard-0804
Aug 21, 2026
Merged

fix(cli): guard onSessionEnd via applicationScope.wo (#3379)#3394
bpamiri merged 2 commits into
developfrom
cursor/onsessionend-scope-guard-0804

Conversation

@bpamiri

@bpamiri bpamiri commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Guard onSessionEnd the same way #3381 guarded onApplicationEnd. Adobe's session reaper (SessionTracker.SessionCleanUpAgent) calls onSessionEnd after the live application scope can already be torn down. Bare application.wo.$simpleLock then throws Element wo is undefined in a Java object of type class [Ljava.lang.String; and the site stays dead until a CF service restart.

Mike already applied the #3381 onApplicationEnd paste; the crash continues at public/Application.cfc onSessionEnd.

This PR routes $simpleLock through arguments.applicationScope.wo and no-ops when wo is missing. Only the wo StructKeyExists guard is added — this path does not $include, so the wheels / eventPath checks from onApplicationEnd are intentionally omitted.

Related Issue

Refs #3379

Type of Change

  • Bug fix
  • New feature
  • Enhancement to existing feature
  • Documentation update
  • Refactoring

What is broken

What was verified

  • All four shipped Application.cfc copies still had the unguarded application.wo.$simpleLock in onSessionEnd on develop before the fix:
    1. cli/lucli/templates/app/public/Application.cfc (canonical wheels new template)
    2. public/Application.cfc (repo demo)
    3. examples/starter-app/public/Application.cfc
    4. examples/tweet/public/Application.cfc
  • Leftover live application.wo in onSessionStart / onRequestStart / onRequestEnd / onMissingTemplate is left alone. Those handlers do not receive applicationScope and run on a live request.
  • onApplicationEnd is unchanged (already shipped via test(cli): cover every shipped onApplicationEnd handler for #3379 #3381).

Spec coverage

vendor/wheels/tests/specs/cli/OnSessionEndScopeGuardSpec.cfc mirrors OnApplicationEndScopeGuardSpec:

  • Discovery walk of cli/lucli/templates, public/, examples/ for every shipped Application.cfc that declares onSessionEnd.
  • Per-file assertions on the onSessionEnd body:
    1. No live application.wo. dereference
    2. Routes through arguments.applicationScope.wo.
    3. StructKeyExists(arguments.applicationScope, "wo") appears before the dereference

TDD: first commit is the failing spec alone; second commit is the four-file guard + changelog fragment so the spec passes.

Existing 4.0.x apps

Existing apps must paste the same onSessionEnd edit into their own public/Application.cfc. Framework upgrades do not rewrite an already-scaffolded application bootstrap.

Feature Completeness Checklist

  • DCO sign-off -- Every commit carries Signed-off-by: (use git commit -s); see CONTRIBUTING.md
  • Tests -- Structural guard spec covering every shipped onSessionEnd handler
  • Framework Docs -- N/A (existing-app paste note lives in CLAUDE.md / .ai sibling of the onApplicationEnd invariant)
  • AI Reference Docs -- Sibling note on .ai/wheels/cross-engine-compatibility.md
  • CLAUDE.md -- Sibling note on invariant 19 (same torn-down-scope rule for onSessionEnd)
  • Changelog fragment -- changelog.d/3379-onsessionend-scope-guard.fixed.md
  • Test runner passes -- CI below must go green

Test Plan

CI that must go green:

  • Bot PR TDD Gate
  • Conventional commit / Validate Commit Messages
  • Smoke: testing (Lucee 7)
  • Smoke: production (Lucee 7)
  • Smoke: testing (Adobe 2023)
  • Smoke: production (Adobe 2023)
  • Lucee 7 + SQLite (LuCLI)

Screenshots / Output

N/A — structural source-shape guard. Real Adobe session-reaper teardown cannot be reproduced inside a spec without killing the runner.

Open in Web Open in Cursor 

cursoragent and others added 2 commits August 21, 2026 15:33
Fails on current develop: every shipped onSessionEnd still
dereferences live application.wo.$simpleLock.

Refs #3379

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: Peter Amiri <peter@alurium.com>
Adobe's session reaper can call onSessionEnd after the live
application scope is already torn down. Route $simpleLock through
arguments.applicationScope.wo and no-op when wo is missing.

Refs #3379

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: Peter Amiri <peter@alurium.com>
@bpamiri
bpamiri merged commit 9be0f41 into develop Aug 21, 2026
12 checks passed
@bpamiri
bpamiri deleted the cursor/onsessionend-scope-guard-0804 branch August 21, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants