Skip to content

fix(demo): handle expired federated credentials gracefully - #50

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/demo-expired-creds
Jul 31, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/demo-expired-creds

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes the "Demo 1: handle expired STS creds gracefully" item.

The bug

Globus→STS sessions are capped at 1 hour (DurationSeconds: 3600). A Demo 1
tab left open past that failed at the next action with a raw SDK error —
Request has expired — which tells the user nothing about what to do.

The demo already had the expiration: credsFromIdToken returns it on
AwsCreds. Nothing read it.

The fix

Tracks it, and follows the same warn-then-expire shape as the portal's
SessionController
— deliberately, so two surfaces don't invent two models of
the same thing.

When What the user sees
Signed in Federated session valid until 6:35 PM (~60 min).
5 min out Banner turns amber + a log line, so a launch isn't started against creds about to lapse
Expired Red banner explaining the 1-hour lifetime + Sign in with Globus again; launch/terminal disabled, monitor stopped, terminal torn down
Signed back in Buttons re-armed, clock re-shown
Pasted long-lived keys No clock at all — they have no expiration

Two details worth noting:

  • Checked at each click, not only on the timer. A laptop asleep past the
    deadline doesn't fire setTimeout on schedule. A 30s tick keeps the "~N min"
    honest and is also what notices that case.
  • onExpiryExpired() is idempotent. It's reachable from the timer, the tick,
    and every guarded click; it should announce once, not once per click.

The poll loop stops itself on expiry with a note that the instance still
self-terminates on its TTL
— true, and the reassuring part: spored owns the
deadline, not this tab. Otherwise each 15s tick would be a failing
DescribeInstances.

Verification — ran it, didn't just typecheck it

demo/direct/expiry.harness.html loads the real main.ts and drives the
real Globus→STS path, stubbing only window.fetch and Date.now so
"expired" is reachable without waiting an hour. The actual
armExpiry/onExpiryWarning/onExpiryExpired code runs — not a copy.

18/18 assertions pass in headless Chrome, covering all three transitions,
both disabled buttons, the re-sign-in affordance, announce-once, the absence of
the old cryptic error
, and the paste path showing no clock. Screenshot checked
(red banner, dimmed launch).

Worth recording: an earlier harness revision reported 5 failures that were
harness bugs, not code bugs — a stray .go click left the button disabled, so
the next click was a no-op that would have silently faked a pass. Fixed by
asserting the precondition that the button is clickable before the click that
matters.

The harness is dev-only: vite.config.ts lists two explicit inputs, and a
real vite build produces no *harness* file (verified).

npm run typecheck (src + demo) ✅ · 309 tests pass ✅

Also closed by inspection, no code needed

The companion item "poll-render status between launch and terminal state" —
status rows only updating at shutdown — no longer reproduces. poll() calls
render(inst) on every 15s tick unconditionally (has since add4366), and
SpawnClient.get() → EC2Provider.get() is a live DescribeInstances with no
cache, so running/public IP/DNS-confirmed do update live. Nothing to fix.

Globus→STS sessions are capped at 1 hour (DurationSeconds: 3600). A Demo 1 tab
left open past that failed at the next action with a raw SDK error — "Request has
expired" — which says nothing about what to do. The demo already had the
expiration: credsFromIdToken returns it on AwsCreds; nothing read it.

Now the demo tracks it and behaves like the portal's SessionController (same
warn-then-expire shape, deliberately: two surfaces shouldn't invent two models):

- A session clock under "Connected to account …" — "valid until 6:35 PM (~60
  min)". Hidden entirely for pasted long-lived keys, which have no expiration.
- 5 minutes out: the banner turns amber and logs a warning, so an in-flight
  launch isn't started against creds about to lapse.
- At expiry: the banner turns red, explains the 1-hour lifetime, and offers
  "Sign in with Globus again". Launch + terminal are disabled, the monitor loop
  is stopped, and any SSM terminal is torn down — otherwise every 15s tick is a
  failing DescribeInstances.
- Signing back in re-arms the buttons and re-shows the clock.

Checked at the moment of each click, not only on the timer: a laptop asleep past
the deadline doesn't fire timeouts on schedule, and the 30s refresh tick that
keeps the "~N min" honest is also what notices that case. onExpiryExpired() is
idempotent — it's reachable from the timer, the tick, and each guarded click, and
should announce once.

The poll loop stops itself on expiry with a note that the instance still
self-terminates on its TTL, which is true and is the reassuring part: spored owns
the deadline, not this tab.

Verified by running it: demo/direct/expiry.harness.html loads the real main.ts
and drives the real Globus→STS path, stubbing only window.fetch and Date.now so
"expired" is reachable without waiting an hour. 18/18 assertions pass in headless
Chrome, covering the fresh/warn/expired transitions, both disabled buttons, the
re-sign-in affordance, announce-once, absence of the old cryptic error, and that
the paste path shows no clock. Screenshot checked. The harness is dev-only —
vite.config.ts lists two explicit inputs, and it's absent from a real build.

typecheck (src + demo) clean; 309 tests pass.
@scttfrdmn
scttfrdmn merged commit 0cc704b into main Jul 31, 2026
1 check passed
@scttfrdmn
scttfrdmn deleted the fix/demo-expired-creds branch July 31, 2026 01:00
scttfrdmn added a commit that referenced this pull request Aug 1, 2026
Cutting 0.7.0 surfaced that the process had already drifted, so this does both:
the release, and the mechanism that stops the drift recurring.

The drift found while reconstructing the notes:

- 0.6.0 and 0.6.1 were both published to npm with NO CHANGELOG section, and
  0.6.0 was never tagged at all. Both sections are now written retroactively
  from the commit range.
- `[Unreleased]` therefore still compared from v0.5.0 and had accumulated
  entries that had already shipped in 0.6.0 (#28, #38). Moved.
- The six audit fixes (#50, #51, #54, #55, #56, #58) had landed on main with no
  CHANGELOG entry at all. Written from the commit bodies.
- publish.yml's subpath guard was a hardcoded list that never gained
  `./transfer` when #59 added that subpath — so the guard had silently stopped
  covering a real entry point. That is the failure mode of a duplicated list, so
  scripts/check-exports.mjs now derives the check from `exports` itself and
  checks every target, not only the .d.ts. Verified it fails on exactly the
  subpath the old list was missing.

New `npm run release:check` is the preflight. Every assertion in it maps to a
drift above rather than to a hypothetical, and each was verified to fail when
violated (undated section, missing compare link, stale [Unreleased] link,
version with no section, already-published version). It reports ALL problems at
once, and a check it cannot run (no git, no network) is reported as unknown
rather than as passing.

It immediately earned itself: it caught LIB_VERSION still reading 0.6.1.
That constant is stamped into the `spawn:version` launch tag and read by Go's
pkg/aws/ami_mgmt.go, so shipping it stale would have mislabelled every instance
launched by 0.7.0. Bumped, and the coupling is now documented at the bump step
in docs/releasing.md rather than left for someone to remember.

docs/releasing.md writes the process down: tag last, tag from main, tag only a
pushed green commit, and never move a published tag — fix forward, as truffle-ts
v0.4.1 did.

0.7.0 is MINOR, not PATCH: `launch` now refuses a spec it previously accepted
(#51) and the unbounded-launch guard changed which options satisfy it (#55). A
type-compatible change that rejects previously-valid input is still a break.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant