Skip to content

Fix typecheck failure in example/convex/setup.test.ts#262

Draft
sethconvex wants to merge 3 commits into
mainfrom
fix-ci-typecheck
Draft

Fix typecheck failure in example/convex/setup.test.ts#262
sethconvex wants to merge 3 commits into
mainfrom
fix-ci-typecheck

Conversation

@sethconvex
Copy link
Copy Markdown
Contributor

@sethconvex sethconvex commented May 10, 2026

Summary

Restores npm run typecheck to green. Main has been failing on every push since 2026-04-01, masking real type regressions in subsequent PRs.

Root cause

Commit e29f2bb ("better convex test types") made @convex-dev/agent's register signature generic. Sibling components didn't all follow:

Package Pinned here Latest Generic register?
@convex-dev/agent this repo
@convex-dev/workflow 0.3.6 0.3.12 ✅ in 0.3.12
@convex-dev/workpool 0.3.1 (transitive) 0.4.6 ✅ in 0.4.x
@convex-dev/rate-limiter 0.3.2 0.3.2 (latest) ❌ still non-generic

TestConvex is invariant in its schema parameter (it appears in both contravariant input positions like t.query(...) args and covariant return positions), so a TestConvex<SchemaDefinition<{ rawUsage: ..., invoices: ... }>> is not assignable to TestConvex<SchemaDefinition<GenericSchema, boolean>> even though the value is structurally compatible.

Fix

  • Bump @convex-dev/workflow 0.3.6 → 0.3.12 (now generic).
  • Add @convex-dev/workpool 0.4.6 as an explicit dev dep so the transitive workpool is upgraded; workflow's own workpool.register(t, ...) would otherwise fail typecheck against the older 0.3.1 workpool.
  • Cast t only at the rateLimiter.register(...) call site — rate-limiter@0.3.2 is the latest published version and still has the non-generic signature. The cast is annotated as a temporary workaround; an upstream PR genericizes rate-limiter's register, and once a new release lands the cast can be deleted.

Test plan

  • npm run typecheck — passes locally (was failing on main for ~6 weeks)
  • npm test — all 262 tests pass
  • npm run lint — clean

Follow-up

  • Upstream PR on get-convex/rate-limiter to genericize register. Once shipped, drop the cast.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/agent@262

commit: 224d882

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The PR updates the initConvexTest function to explicitly parameterize the convexTest constructor with GenericSchema. The type import is added from convex/server, and the instantiation now passes the generic parameter. Inline comments explain that this schema-type widening aligns the resulting TestConvex instance with the non-generic register signatures of @convex-dev/workflow and @convex-dev/rate-limiter, addressing TestConvex's invariance in its schema type. The runtime registration flow with agent, workflow, and rateLimiter remains unchanged.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: fixing a typecheck failure in a specific file. It is clear, specific, and accurately summarizes the primary fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description comprehensively explains the root cause of the typecheck failure, the dependencies involved, and the specific fix applied, directly relating to all changes in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-ci-typecheck

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 and usage tips.

@sethconvex sethconvex marked this pull request as draft May 10, 2026 04:50
Main has been failing `npm run typecheck` on every push since 2026-04-01,
masking real type regressions in subsequent PRs.

Root cause: commit e29f2bb made @convex-dev/agent's `register` signature
generic, so it accepts a `TestConvex` with a specifically-inferred schema.
But sibling components @convex-dev/workflow, /workpool, and /rate-limiter
still shipped non-generic `register(t: TestConvex<SchemaDefinition<
GenericSchema, boolean>>)`. TestConvex is invariant in its schema param,
so a specifically-typed `t` is not assignable to the wider type, and the
example's `initConvexTest` failed to type-check on lines 13-14.

Fix:
- Bump @convex-dev/workflow 0.3.6 -> 0.3.12 (now generic).
- Add @convex-dev/workpool 0.4.6 explicitly as a dev dep so the
  transitive workpool is upgraded too (previously pinned at 0.3.1, still
  non-generic). Workflow's internal `workpool.register(t, ...)` call was
  itself failing with the older workpool.
- Cast `t` only at the rate-limiter call: rate-limiter@0.3.2 is the
  latest published version and still has the non-generic signature, so
  this cast is a temporary workaround. A separate upstream PR genericizes
  rate-limiter's register; once a new rate-limiter ships, the cast can
  be removed.

After this change: `npm run typecheck`, `npm test`, and `npm run lint`
all pass.
rag@0.7.2 pinned workpool to ^0.3.0, conflicting with the workpool 0.4.6
upgrade in the prior commit. rag@0.7.3 widens its peer to
^0.3.0 || ^0.4.0, so a clean npm install now works.
Copy link
Copy Markdown
Member

@ianmacartney ianmacartney left a comment

Choose a reason for hiding this comment

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

I think we can drop this if we update convex-test

convex-test 0.0.52 relaxes TestConvex's schema-param variance enough
that a specifically-typed `t` is now assignable to non-generic register
signatures like @convex-dev/rate-limiter@0.3.2's. The workaround cast
in initConvexTest is no longer needed.
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