fix: resolve MetaCollection initialization error and add CI typecheck#188
Merged
Conversation
…check - Remove top-level await in TaskMeta.ts that blocked MetaCollection export initialization, causing 'Cannot access MetaCollection before initialization' in gh-bugcop.tsx and other importers - Make createIndex lazy (called on first $upsert/save) instead of at import time - Fix type error in gh-design.ts (task._id access in union type) - Add 'bun run check' (tsgo + oxlint + oxfmt) to CI test workflow - Fix husky pre-commit shebang (sh instead of bun) and run typecheck Amp-Thread-ID: https://ampcode.com/threads/T-019d5268-b3d3-73db-8560-91bd9404fe73 Co-authored-by: Amp <amp@ampcode.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a runtime crash caused by a top-level await in the TaskMeta module and adds typecheck/check enforcement in local hooks and CI to prevent similar regressions.
Changes:
- Replaced
await createIndex()at module import time with lazy index initialization inside TaskMeta$upsert/save. - Fixed a TypeScript error in
gh-designby adjusting_idaccess typing. - Added
bun run checkto CI and updated the pre-commit hook to runbun run typecheck.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/db/TaskMeta.ts |
Removes top-level await by lazily creating the unique coll index on first use. |
app/tasks/gh-design/gh-design.ts |
Adjusts formatting and changes _id access typing to resolve a type error. |
.husky/pre-commit |
Updates hook interpreter and adds a typecheck step before lint-staged. |
.github/workflows/test.yaml |
Adds a bun run check step to CI prior to running tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
snomiao
enabled auto-merge (squash)
April 3, 2026 08:30
- scripts/cleanup-slack-dupes.ts: replace 'as any' with proper types - slackPendingLock.spec.ts: add error field to LockState type Amp-Thread-ID: https://ampcode.com/threads/T-019d5268-b3d3-73db-8560-91bd9404fe73 Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bun app/tasks/run-gh-tasks.tscrashes with:Root Cause
src/db/TaskMeta.tshad a top-levelawait _TaskMeta.createIndex(...)that blocked module initialization. Whengh-bugcop.tsximportsMetaCollection, the export is still in the temporal dead zone because the top-level await hasn't resolved yet.Fix
src/db/TaskMeta.ts: Replace top-levelawait createIndex()with lazy initialization — the index is created on first $upsert/save call instead of at import time.app/tasks/gh-design/gh-design.ts: Fix pre-existing type error (task._idon union type).Prevention
.husky/pre-commit: Fix shebang (shinstead ofbun) and runbun run typecheck(tsgo) before every commit..github/workflows/test.yaml: Addbun run check(tsgo + oxlint + oxfmt) step to CI so PRs are checked.