server: a deferred create can still attach during an UNFORCED environment destroy's backend teardown

Open
#9,511 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
47/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
backend, testing

Research direction

Read the decision doc at docs/decisions/2026-08-destroy-environment-live-sessions.md and the related issue #9509 test that records the current unforced-path behavior. Trace deferred create through SessionManager.createSession and EnvironmentManager.addSession while backend teardown is pending. Add a test that proves the late session is refused or receives session_destroyed, and verify it fails against main.

Written by the indexing model from the issue text.

Description

from-review server tech-debt

Context

Split from #9509. Its fix makes a FORCED environment destroy call the cascade's onLiveSessions a second time, after a successful backend teardown and before the environment record is deleted. A session a deferred create attaches during the teardown is then torn down, with session_destroyed, instead of being left on a removed container.

The remaining window

An UNFORCED destroy refuses with ENVIRONMENT_HAS_LIVE_SESSIONS when sessions are attached at lock time, and never hands sessions to onLiveSessions. That refusal is the policy in docs/decisions/2026-08-destroy-environment-live-sessions.md: an unforced destroy has no consent to destroy a session.

A deferred create (for example a user-shell create held for host approval) replays container info it captured earlier and never calls getContainerInfo. If it attaches through SessionManager.createSession → EnvironmentManager.addSession while an unforced destroy is awaiting its backend teardown, the same thing #9509 fixed for the forced path happens here:

  • the container is removed and the environment record is deleted;
  • the session stays in SessionManager._sessions on a removed container;
  • no session_destroyed is broadcast.

The #9509 test file pins the current behaviour: "the UNFORCED path does not hand attached sessions to onLiveSessions".

The decision needed

Closing this changes what an unforced destroy may do, so it is a policy question for the decision doc, not just an implementation one. Two options:

  • Tear the straggler down anyway. Its container is already gone, so the session cannot work either way. Run the same post-teardown onLiveSessions call on the unforced path. The refusal at lock time is unchanged.
  • Refuse the late attach at the deferred replay step. The deferred path re-reads getContainerInfo before it attaches. This touches the deferred/host-approval pipeline.

Acceptance

  • The decision doc records which option, and why.
  • A test drives a deferred attach during an UNFORCED destroy's backend teardown, and shows the session is either refused or torn down with session_destroyed, never left on the removed container.
  • The test is proven red against main.
Dominant language
JavaScript
Stars
7
Forks
1
Avg merge
2h 3m
Merged PRs (30d)
333

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from blamechris/chroxy

All issues in blamechris/chroxy

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.