Skip to content

fix(onboarding): ignore a job title eligibility check superseded by newer values - #1420

Closed
gabrielseco wants to merge 1 commit into
found-1869-eligibility-result-into-schemafrom
found-1869-superseded-eligibility-guard
Closed

gabrielseco wants to merge 1 commit into
found-1869-eligibility-result-into-schemafrom
found-1869-superseded-eligibility-guard

Conversation

@gabrielseco

Copy link
Copy Markdown
Collaborator

Summary

If a custom onboarding UI starts a second job title eligibility check before the first one finishes, the older check's result can no longer overwrite the newer one's.

Why

Cursor Bugbot flagged this on #1417. It only reproduces when checkJobTitleEligibility is called twice before React re-renders. Today the only caller is the prebuilt form's onBlur. There, React Query already aborts a superseded check, because a re-render always happens between user-driven blurs.

Parked as a separate PR so we can decide later whether we need it, for example if partners end up calling checkJobTitleEligibility themselves.

What changed

Toggle details
  • useJobTitleEligibilityCheck.tsx: once the request settles, check() compares the params it sent with the latest ones (paramsRef). If they differ, it resolves with undefined instead of the result, or instead of cleared values on failure, and it skips the error log. The prebuilt form writes nothing for undefined.
  • Why React Query doesn't cover it: React Query only aborts a query when its last useQuery observer goes away. Two back-to-back calls leave the first query without any observer, so nothing cancels it. The same happens if its response lands before the re-render that would switch the observer.
  • Tests:
    • Two back-to-back headless checks: one where the stale request succeeds and one where it fails. Both fail without the fix.
    • A UI test for Bugbot's exact scenario (clear the role fields while a check is in flight). It already passes without the fix and documents that React Query's abort covers the prebuilt form.
  • No public API change. This makes the existing JSDoc promise ("resolves with undefined when a newer check superseded it") hold regardless of render timing.

Screenshots

N/A

Related Resources

Testing

  • Tested against the example/ app in a browser
  • Feature flag: job_title_eligibility

🤖 Generated with Claude Code

…ewer values

When two checks fire before React re-renders, the older query never gets an
observer, so React Query doesn't abort it. Its result, or its failure, then
overwrote the newer check's values. check() now resolves with undefined when the
params it sent are no longer the latest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Metric Current Previous Change Status
Total (gzip) 168.32 kB 168.3 kB +21 B (+0.0%) 🔴
Total (raw) 562.39 kB 562.34 kB +50 B (+0.0%) 🔴
CSS (gzip) 21.94 kB 21.94 kB 0 B (0%) 🟢
CSS (raw) 114.43 kB 114.43 kB 0 B (0%) 🟢

Size Limits

  • ✅ Total gzipped: 168.32 kB / 350 kB (48.1%)
  • ✅ Total raw: 562.39 kB / 850 kB (66.2%)
  • ✅ CSS gzipped: 21.94 kB / 25 kB (87.8%)

Largest Files (Top 5)

  1. CheckBoxField-DBWQDi6N.js - 24.64 kB (0 B (0%))
  2. ContractorOnboarding-BnDzNq87.js - 13.54 kB (0 B (0%))
  3. Onboarding-BE8co2yR.js - 11.83 kB (new)
  4. Termination-CG2zDxEl.js - 11.07 kB (0 B (0%))
  5. styles.css - 10.97 kB (0 B (0%))
View All Files (75 total)
File Size (gzip) Change
CheckBoxField-DBWQDi6N.js 24.64 kB 0 B (0%)
ContractorOnboarding-BnDzNq87.js 13.54 kB 0 B (0%)
Onboarding-BE8co2yR.js 11.83 kB new
Termination-CG2zDxEl.js 11.07 kB 0 B (0%)
styles.css 10.97 kB 0 B (0%)
index.css 10.97 kB 0 B (0%)
CostCalculator-DQd2Jyj4.js 10.65 kB 0 B (0%)
internals-DXMceODY.js 8.23 kB 0 B (0%)
index.js 5.05 kB 0 B (0%)
JSONSchemaForm-D8Xz5yJL.js 4.9 kB 0 B (0%)

✅ Bundle size check passed

@github-actions

Copy link
Copy Markdown
Contributor

Deploy preview for remote-flows ready!

Project:remote-flows
Status: ✅  Deploy successful!
Preview URL:https://remote-flows-laa1g11or-remotecom.vercel.app
Latest Commit:9cb7455

Deployed with vercel-action

@github-actions

Copy link
Copy Markdown
Contributor

Deploy preview for adp-cost-calculator ready!

Project:adp-cost-calculator
Status: ✅  Deploy successful!
Preview URL:https://adp-cost-calculator-djppqhu32-remotecom.vercel.app
Latest Commit:9cb7455

Deployed with vercel-action

@github-actions

Copy link
Copy Markdown
Contributor

📊 Coverage Report

✅ Coverage increased! 🎉

Metric Current Previous Change Status
Lines 86.54% 86.54% 0% ⚪
Statements 86.11% 86.10% 0% ⚪
Functions 85.10% 85.09% 0% ⚪
Branches 78.08% 78.05% +0.02% 🟢

Detailed Breakdown

Lines Coverage
  • Covered: 4926 / 5692
  • Coverage: 86.54%
  • Change: 0% (3 lines)
Statements Coverage
  • Covered: 5011 / 5819
  • Coverage: 86.11%
  • Change: 0% (4 statements)
Functions Coverage
  • Covered: 1308 / 1537
  • Coverage: 85.10%
  • Change: 0% (1 functions)
Branches Coverage
  • Covered: 3059 / 3918
  • Coverage: 78.08%
  • Change: +0.02% (4 branches)

✅ Coverage check passed

@remotecom remotecom closed this Oct 7, 2026
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.

2 participants