Skip to content

fix(web): handle Turnstile siteverify failures with typed 503 (fixes #64) - #300

Open
NePreby wants to merge 1 commit into
vouchlabsio:mainfrom
NePreby:fix/turnstile-siteverify-failures-resilience
Open

NePreby wants to merge 1 commit into
vouchlabsio:mainfrom
NePreby:fix/turnstile-siteverify-failures-resilience

Conversation

@NePreby

@NePreby NePreby commented Nov 7, 2026

Copy link
Copy Markdown

Overview

Resolves #64 by making Turnstile human verification resilient against network interruptions, unreachable Cloudflare endpoints, and non-JSON responses from siteverify.

Changes

  1. Server Endpoint (packages/web/server/api/verify-human.post.ts):
    • Wrapped the siteverify fetch(...) call in a try/catch block. Network/transport rejections return HTTP 503 with { success: false, error: "verification service unavailable" }.
    • Wrapped res.json() in a try/catch block. Malformed/non-JSON responses return HTTP 503 with { success: false, error: "malformed verification response" }.
    • Resolved merge collision artifact to ensure consistent handler structure.
  2. Client Component (packages/web/app.vue):
    • Updated onHumanToken() error handler to inspect status code 503.
    • Distinguishes service outages ("verification service unavailable — please try again later") from failed bot challenges ("human check failed — try again").
  3. Unit Test Suite (packages/web/test/verify-human.test.ts):
    • Added test verifying rejected fetch returns HTTP 503 without uncaught exceptions.
    • Added test verifying non-JSON response returns HTTP 503 without uncaught exceptions.
    • Verified 8 of 8 tests pass cleanly.

Closes #64


Contributor Payout

  • Network: TRX Tron (TRC20)
  • Address: TMqmJjRgVS21NL2eFtfyHciTxvE4BqGmEv

…ent resilience (fixes vouchlabsio#64)

- Wrap Cloudflare siteverify fetch and JSON parsing in try/catch blocks
- Return HTTP 503 Service Unavailable with { success: false, error } on transport or parse failures
- Update app.vue onHumanToken to distinguish failed human checks from service unavailability
- Add vitest tests for network timeout rejection and malformed non-JSON response

Closes vouchlabsio#64
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.

[Bounty: $50] Handle Turnstile siteverify failures without throwing a 500

1 participant