Skip to content

fix(evoting): stop false "failed to create session" error after a successful vote#1067

Open
Bekiboo wants to merge 3 commits into
mainfrom
fix/evoting-signing-false-error-after-vote
Open

fix(evoting): stop false "failed to create session" error after a successful vote#1067
Bekiboo wants to merge 3 commits into
mainfrom
fix/evoting-signing-false-error-after-vote

Conversation

@Bekiboo

@Bekiboo Bekiboo commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Description of change

The eVoting "Sign your vote" screen showed "Failed to create signing session" (with a "Try Again" prompt) even when the vote had actually been signed and recorded — specifically on mobile, when the eID Wallet was closed and biometric verification was required.

Root cause: the "signed" result reaches the web page only as a one-shot SSE push. Opening the eID Wallet backgrounds the browser, which suspends the SSE stream, so the completion event is lost; on return, the SSE onerror was mislabeled as a session-creation failure.

Issue Number

Closes #1059

Type of change

  • Fix (a change which fixes an issue)

How the change has been tested

  • tsc --noEmit clean on both evoting/api and evoting/client.
  • Not yet re-run end-to-end on a device.

Change checklist

  • I have ensured that the CI Checks pass locally
  • I have removed any unnecessary logic
  • My code is well documented
  • I have signed my commits
  • My code follows the pattern of the application
  • I have self reviewed my code

Design notes

  • API: the SSE status stream now replays the current terminal state (completed / security_violation / expired) on every (re)connect, so a reconnecting client immediately catches a completion it missed. Idempotent on the client.
  • Client: an SSE drop is no longer treated as a fatal "failed to create session" — the client reconciles the authoritative session status on SSE error and whenever the tab regains focus/visibility. The completion path is guarded to run exactly once.

Summary by CodeRabbit

  • New Features

    • Signing status now recovers more reliably after reconnects or when the app returns to the foreground.
    • The interface can now refresh the current signing result and show the correct final state even if a live update was missed.
  • Bug Fixes

    • Improved handling for completed, expired, and security-related signing sessions.
    • Reduced cases where signing could appear to fail due to interrupted live updates.

@Bekiboo Bekiboo self-assigned this Jul 1, 2026
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Bekiboo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 88e42134-173c-4e49-975b-b578bb1a042e

📥 Commits

Reviewing files that changed from the base of the PR and between e7c206b and bf3610b.

📒 Files selected for processing (2)
  • platforms/evoting/api/src/controllers/SigningController.ts
  • platforms/evoting/client/src/lib/pollApi.ts
📝 Walkthrough

Walkthrough

The SigningController now replays terminal signing session status on SSE (re)connect. pollApi adds a getSigningSession method to fetch current session status. The signing-interface component adds idempotent completion handling (finishAsSigned, reconcileSession) triggered by SSE messages, errors, and tab visibility/focus changes.

Changes

Signing session reconciliation

Layer / File(s) Summary
Server-side SSE replay on connect
platforms/evoting/api/src/controllers/SigningController.ts
On SSE (re)connect, fetches current session via service.getSession(sessionId) and replays terminal status (completed, security_violation, expired) to the client, with error logging.
Client API for session status fetch
platforms/evoting/client/src/lib/pollApi.ts
Adds getSigningSession(sessionId) to fetch { status, voteId } from /api/signing/sessions/{sessionId}.
Idempotent completion and reconciliation logic
platforms/evoting/client/src/components/signing-interface.tsx
Adds hasCompleted guard and finishAsSigned to centralize completion side effects, reconcileSession to re-fetch authoritative status via pollApi, wires these into SSE message/error handlers and a new visibility/focus effect to recover state when the tab regains focus.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SigningInterface
  participant SigningController
  participant pollApi

  User->>SigningInterface: initiate signing
  SigningInterface->>SigningController: open SSE connection
  SigningController->>SigningController: getSession(sessionId)
  SigningController-->>SigningInterface: replay status if terminal

  alt SSE delivers signed event
    SigningController-->>SigningInterface: signed message
    SigningInterface->>SigningInterface: finishAsSigned(voteId)
  else SSE error occurs
    SigningInterface->>pollApi: getSigningSession(sessionId)
    pollApi-->>SigningInterface: status, voteId
    SigningInterface->>SigningInterface: reconcileSession updates UI
  else tab regains visibility/focus
    SigningInterface->>pollApi: getSigningSession(sessionId)
    pollApi-->>SigningInterface: status, voteId
    SigningInterface->>SigningInterface: reconcileSession updates UI
  end
Loading

Suggested reviewers: sosweetham, xPathin

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main fix: suppressing a false signing-session error after a successful vote.
Description check ✅ Passed The description follows the template and includes the issue, type, testing, checklist, and design notes.
Linked Issues check ✅ Passed The code replays terminal SSE states and reconciles client status on reconnect, matching issue #1059's success-after-signing fix.
Out of Scope Changes check ✅ Passed The changes stay focused on SSE replay and client reconciliation needed for the signing-session error fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/evoting-signing-false-error-after-vote

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Bekiboo Bekiboo marked this pull request as ready for review July 1, 2026 10:24
@Bekiboo Bekiboo requested a review from coodos as a code owner July 1, 2026 10:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@platforms/evoting/api/src/controllers/SigningController.ts`:
- Around line 93-115: The SSE reconnect flow in SigningController’s
subscribe/replay path can leak a subscription if the client disconnects while
awaiting getSession(). Move the req.on("close") cleanup registration to
immediately after subscribeToSession() in SigningController so the unsubscribe
handler is attached before any await, and keep the replay logic for
completed/security_violation/expired states unchanged.

In `@platforms/evoting/client/src/lib/pollApi.ts`:
- Around line 308-312: The getSigningSession wrapper currently advertises a
nullable return type but never actually returns null. Update getSigningSession
to either catch the 404/not-found response from apiClient.get and return null
explicitly, or remove null from the return type if callers should always receive
a session object. Make the behavior and signature consistent so callers of
getSigningSession do not depend on an unreachable null path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1b8d9cf8-a538-40fd-b2c3-7bbc70053c4c

📥 Commits

Reviewing files that changed from the base of the PR and between c6f8c3e and e7c206b.

📒 Files selected for processing (3)
  • platforms/evoting/api/src/controllers/SigningController.ts
  • platforms/evoting/client/src/components/signing-interface.tsx
  • platforms/evoting/client/src/lib/pollApi.ts

Comment thread platforms/evoting/api/src/controllers/SigningController.ts Outdated
Comment thread platforms/evoting/client/src/lib/pollApi.ts Outdated
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.

eVoting: "Failed to create signing session" error shown after successful vote submission

1 participant