feat(remote): end a remote session when its client is gone

This commit is contained in:
imSp4rky
2026-11-30 17:23:35 -07:00
parent e813737506
commit ffe812f054
13 changed files with 747 additions and 53 deletions
+4 -1
View File
@@ -24,6 +24,7 @@ from tests.remote.sessions import stub_service_build
from tests.remote.unit.test_tunnel import wait_until
from unshackle.core import remote_channel, remote_service
from unshackle.core.api import handlers, routes, session_store
from unshackle.core.api.client_presence import LEFT_LIMIT
from unshackle.core.api.errors import APIError
from unshackle.core.api.handlers import api_key_authentication
from unshackle.core.api.routes import cors_middleware, no_5xx_middleware, setup_routes
@@ -502,9 +503,11 @@ def test_an_open_channel_keeps_the_session_alive(server: SimpleNamespace, monkey
assert count(server, "GET", SESSION_ROUTE, session_id) == 0
assert count(server, "GET", LOGS_ROUTE) == count(server, "GET", PROMPT_ROUTE) == 0
monkeypatch.setitem(config.serve, "session_ttl", 300)
service.lifetime.close_channel()
assert wait_until(lambda: not entry.channel.attached, 5)
assert wait_until(lambda: entry.idle_seconds > 2 * ttl, 10)
assert on_loop(server, store.cleanup_expired()) == 0
entry.presence.seen_at -= LEFT_LIMIT + 1
assert on_loop(server, store.cleanup_expired()) == 1
assert store.peek(session_id) is None
assert count(server, "GET", SESSION_ROUTE, session_id) == 0