update events and jobs syntax#54
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
💤 Files with no reviewable changes (5)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds typed ChangesTyped dispatch methods on event and queue job definitions
Documentation landing page, deployment model, and discovery workflow
Blog post indexing via events and queue jobs across three frameworks
CLI and core package updates for job definition dispatch
Sequence Diagram(s)sequenceDiagram
participant App as Application Code
participant EventDef as UserRegistered (DefinedEventDefinition)
participant dispatchFn as dispatchDefinedEvent
participant Global as globalThis.__holoEventDefinitionDispatcher__
participant Runtime as events runtime dispatchEvent
participant PD as EventPendingDispatch
App->>EventDef: UserRegistered.dispatch({ userId, email })
EventDef->>dispatchFn: dispatchDefinedEvent(eventDef, payload)
dispatchFn->>Global: getEventDefinitionDispatcher()
Global-->>dispatchFn: dispatchEvent fn
dispatchFn->>Runtime: dispatchEvent(eventDef, payload)
Runtime-->>PD: new EventPendingDispatch(...)
PD-->>App: .afterCommit() chain available
sequenceDiagram
participant App as Application Code
participant JobDef as SendDigest (DefinedQueueJobDefinition)
participant dispatchFn as dispatchDefinedQueueJob
participant WM as jobDefinitionNames WeakMap
participant Global as globalThis queue dispatcher
participant Runtime as queue runtime dispatch
participant PD as QueuePendingDispatch
Note over WM: populated at registerQueueJob() time
App->>JobDef: SendDigest.dispatch({ reportId })
JobDef->>dispatchFn: dispatchDefinedQueueJob(jobDef, payload)
dispatchFn->>WM: resolveQueueJobDefinitionName(jobDef)
WM-->>dispatchFn: "reports.send-digest"
dispatchFn->>Global: getQueueJobDispatcher()
Global-->>dispatchFn: dispatch fn
dispatchFn->>Runtime: dispatch("reports.send-digest", payload)
Runtime-->>PD: new QueuePendingDispatch(...)
PD-->>App: chainable dispatch handle
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/docs/docs/.vitepress/theme/components/Landing.vue`:
- Line 106: The span element in the Landing.vue component containing "+ 7 more
modules" incorrectly displays the count of remaining unpicked modules. Since the
palette shows 8 total modules with 3 marked as picked, only 5 modules remain
unpicked, not 7. Either update the text to display "+ 5 more modules" to
accurately reflect the unpicked module count, or alternatively reframe the link
text to direct users to explore all available modules below (such as "Explore
all modules" or "View complete modules list") and ensure it links to the
appropriate Modules section anchor if using the second approach.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e8580bfb-75af-4dba-bf1b-d7b414880214
📒 Files selected for processing (36)
apps/docs/docs/.vitepress/theme/components/Landing.vueapps/docs/docs/architecture.mdapps/docs/docs/auth/personal-access-tokens.mdapps/docs/docs/broadcast/deployment-and-scaling.mdapps/docs/docs/database/commands.mdapps/docs/docs/deployment.mdapps/docs/docs/directory-structure.mdapps/docs/docs/events/api-reference.mdapps/docs/docs/events/defining-events.mdapps/docs/docs/events/dispatching-events.mdapps/docs/docs/events/index.mdapps/docs/docs/events/queued-listeners.mdapps/docs/docs/events/setup-and-cli.mdapps/docs/docs/events/transactions-after-commit.mdapps/docs/docs/index.mdapps/docs/docs/mail/queueing-mail.mdapps/docs/docs/media.mdapps/docs/docs/notifications/queueing-notifications.mdapps/docs/docs/queue/index.mdapps/docs/docs/queue/jobs.mdapps/docs/docs/queue/workers.mdapps/docs/docs/realtime/index.mdapps/docs/docs/runtime-services.mdpackages/events/src/contracts.tspackages/events/src/index.tspackages/events/src/runtime.tspackages/events/tests/contracts.test.tspackages/events/tests/contracts.type.test.tspackages/events/tests/runtime.test.tspackages/queue/src/contracts.tspackages/queue/src/index.tspackages/queue/src/registry.tspackages/queue/src/runtime.tspackages/queue/tests/config.type.test.tspackages/queue/tests/job.test.tspackages/queue/tests/runtime.test.ts
There was a problem hiding this comment.
Actionable comments posted: 9
🤖 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 `@apps/blog-next/server/lib/blog.ts`:
- Around line 265-268: The IndexBlogPost.dispatch() calls at lines 265, 312, and
332 are creating duplicate indexing jobs because the save event listener in
apps/blog-next/server/listeners/blog/index-saved-post.ts already enqueues the
indexing job automatically. Remove all three IndexBlogPost.dispatch() calls (the
ones with action 'created', action 'updated', and action 'deleted' respectively)
to eliminate the double-queueing behavior and rely solely on the listener to
handle the indexing job dispatch.
In `@apps/blog-next/server/listeners/blog/index-saved-post.ts`:
- Around line 8-12: In the handle method of the blog post listener, replace the
`dispatchSync` call on `IndexBlogPost` with the asynchronous `dispatch` method
to ensure background processing instead of inline execution. This will prevent
blocking the event handler and decouple failure scenarios. Simply change
`IndexBlogPost.dispatchSync` to `IndexBlogPost.dispatch` while keeping the same
payload parameters.
In `@apps/blog-nuxt/server/lib/blog.ts`:
- Around line 236-247: Remove the direct IndexBlogPost.dispatch() calls that
follow the BlogPostSaved.dispatch() calls, as the BlogPostSaved event listener
in apps/blog-nuxt/server/listeners/blog/index-saved-post.ts already triggers
IndexBlogPost dispatching. Keep only the BlogPostSaved.dispatch() calls to
maintain a single indexing path through the event listener, and apply this same
fix to all occurrences where both BlogPostSaved and IndexBlogPost are dispatched
together in the same lifecycle handler blocks.
In `@apps/blog-nuxt/server/listeners/blog/index-saved-post.ts`:
- Around line 8-12: The handle method in the event listener is using
IndexBlogPost.dispatchSync which blocks the handler while processing. Change the
dispatchSync call to an asynchronous dispatch method (typically dispatch instead
of dispatchSync) to queue the indexing job in the background without blocking
the handler. This ensures the listener returns immediately after queuing the job
rather than waiting for the indexing to complete.
In `@apps/blog-sveltekit/server/listeners/blog/index-saved-post.ts`:
- Around line 8-12: The handle method uses dispatchSync for IndexBlogPost which
blocks the main request/event flow. Replace dispatchSync with the asynchronous
dispatch method and ensure proper await handling to move the indexing operation
into a background queue instead of the critical path. This allows the event to
complete without waiting for the indexing to finish.
In `@apps/blog-sveltekit/src/routes/admin/posts/`[id]/edit/+page.server.ts:
- Around line 68-78: The update flow is dispatching both
BlogPostSaved.dispatch() and IndexBlogPost.dispatch() which causes indexing to
be triggered twice - once by the BlogPostSaved listener and once by the direct
IndexBlogPost.dispatch() call. Remove the IndexBlogPost.dispatch() call that is
invoked after BlogPostSaved.dispatch() on the queue, keeping only the
BlogPostSaved.dispatch() which already handles triggering the indexing through
its listener.
In `@apps/blog-sveltekit/src/routes/admin/posts/`+page.server.ts:
- Around line 30-40: The code is dispatching BlogPostSaved event which has a
listener that already dispatches IndexBlogPost for indexing, and then directly
dispatching IndexBlogPost again, causing duplicate indexing work for the same
delete action. Remove the direct IndexBlogPost.dispatch() call that appears
after the BlogPostSaved.dispatch() invocation, and rely solely on the
event-driven approach where the BlogPostSaved listener handles the IndexBlogPost
dispatch.
In `@apps/blog-sveltekit/src/routes/admin/posts/new/`+page.server.ts:
- Around line 63-73: The code is dispatching two separate events for the same
create operation: BlogPostSaved and IndexBlogPost, which causes duplicate
indexing work. Since BlogPostSaved is already configured to trigger indexing,
remove the direct IndexBlogPost.dispatch() call on line 70 and rely solely on
the BlogPostSaved event dispatch to handle the indexing through its wired event
handler.
In `@packages/cli/src/queue-migrations.ts`:
- Around line 33-35: The escapeSingleQuotedString function only escapes
backslashes and single quotes but fails to handle control characters like
newline and carriage return that can appear in table names. These unescaped
control characters will break the generated TypeScript code in the migration
file. Replace the current manual replaceAll approach in escapeSingleQuotedString
with JSON.stringify() which automatically handles all control character escaping
correctly.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 663163f9-7f5a-44b4-99e7-a89fdff8e2b9
⛔ Files ignored due to path filters (2)
apps/docs/docs/public/mark.svgis excluded by!**/*.svgbun.lockis excluded by!**/*.lock
📒 Files selected for processing (70)
apps/blog-next/package.jsonapps/blog-next/server/db/migrations/2026_04_25_044031_create_admins.tsapps/blog-next/server/db/migrations/2026_04_25_044032_create_notifications.tsapps/blog-next/server/db/migrations/2026_04_25_044032_create_users.tsapps/blog-next/server/db/migrations/2026_04_25_044033_create_sessions.tsapps/blog-next/server/db/migrations/2026_04_25_044034_create_auth_identities.tsapps/blog-next/server/db/migrations/2026_04_25_044035_create_personal_access_tokens.tsapps/blog-next/server/db/migrations/2026_04_25_044036_create_password_reset_tokens.tsapps/blog-next/server/db/migrations/2026_04_25_044037_create_email_verification_tokens.tsapps/blog-next/server/db/migrations/2026_05_02_115334_create_comments_table.tsapps/blog-next/server/db/migrations/2026_05_25_063242_create_cache_cache_table.tsapps/blog-next/server/db/migrations/2026_06_19_202222_create_failed_jobs_table.tsapps/blog-next/server/db/migrations/2026_06_19_202222_create_jobs_table.tsapps/blog-next/server/events/blog/post-saved.tsapps/blog-next/server/jobs/blog/index-post.tsapps/blog-next/server/lib/blog.tsapps/blog-next/server/listeners/blog/index-saved-post.tsapps/blog-next/tests/blog-logic.mjsapps/blog-nuxt/package.jsonapps/blog-nuxt/server/db/migrations/2026_04_25_044031_create_admins.tsapps/blog-nuxt/server/db/migrations/2026_04_25_044032_create_notifications.tsapps/blog-nuxt/server/db/migrations/2026_04_25_044032_create_users.tsapps/blog-nuxt/server/db/migrations/2026_04_25_044033_create_sessions.tsapps/blog-nuxt/server/db/migrations/2026_04_25_044034_create_auth_identities.tsapps/blog-nuxt/server/db/migrations/2026_04_25_044035_create_personal_access_tokens.tsapps/blog-nuxt/server/db/migrations/2026_04_25_044036_create_password_reset_tokens.tsapps/blog-nuxt/server/db/migrations/2026_04_25_044037_create_email_verification_tokens.tsapps/blog-nuxt/server/db/migrations/2026_05_02_115438_create_comments_table.tsapps/blog-nuxt/server/db/migrations/2026_05_25_063246_create_cache_cache_table.tsapps/blog-nuxt/server/db/migrations/2026_06_19_202226_create_jobs_table.tsapps/blog-nuxt/server/db/migrations/2026_06_19_202227_create_failed_jobs_table.tsapps/blog-nuxt/server/events/blog/post-saved.tsapps/blog-nuxt/server/jobs/blog/index-post.tsapps/blog-nuxt/server/lib/blog.tsapps/blog-nuxt/server/listeners/blog/index-saved-post.tsapps/blog-nuxt/tests/blog-logic.mjsapps/blog-sveltekit/package.jsonapps/blog-sveltekit/server/db/migrations/2026_04_25_044031_create_admins.tsapps/blog-sveltekit/server/db/migrations/2026_04_25_044032_create_notifications.tsapps/blog-sveltekit/server/db/migrations/2026_04_25_044032_create_users.tsapps/blog-sveltekit/server/db/migrations/2026_04_25_044033_create_sessions.tsapps/blog-sveltekit/server/db/migrations/2026_04_25_044034_create_auth_identities.tsapps/blog-sveltekit/server/db/migrations/2026_04_25_044035_create_personal_access_tokens.tsapps/blog-sveltekit/server/db/migrations/2026_04_25_044036_create_password_reset_tokens.tsapps/blog-sveltekit/server/db/migrations/2026_04_25_044037_create_email_verification_tokens.tsapps/blog-sveltekit/server/db/migrations/2026_05_02_115430_create_comments_table.tsapps/blog-sveltekit/server/db/migrations/2026_05_25_063252_create_cache_cache_table.tsapps/blog-sveltekit/server/db/migrations/2026_06_19_202238_create_jobs_table.tsapps/blog-sveltekit/server/db/migrations/2026_06_19_202239_create_failed_jobs_table.tsapps/blog-sveltekit/server/events/blog/post-saved.tsapps/blog-sveltekit/server/jobs/blog/index-post.tsapps/blog-sveltekit/server/listeners/blog/index-saved-post.tsapps/blog-sveltekit/src/routes/admin/posts/+page.server.tsapps/blog-sveltekit/src/routes/admin/posts/[id]/edit/+page.server.tsapps/blog-sveltekit/src/routes/admin/posts/new/+page.server.tsapps/blog-sveltekit/tests/blog-logic.mjsapps/docs/docs/.vitepress/theme/components/Landing.vueapps/docs/docs/queue/jobs.mdpackages/cli/src/cache-migrations.tspackages/cli/src/media-migrations.tspackages/cli/src/project/scaffold/project-renderers.tspackages/cli/src/queue-migrations.tspackages/cli/src/queue.tspackages/cli/tests/queue-migrations.test.tspackages/core/src/portable/holo.tspackages/core/tests/adapter.test.tspackages/core/tests/runtime.test.tspackages/queue/src/contracts.tspackages/queue/src/registry.tspackages/queue/tests/config.type.test.ts
✅ Files skipped from review due to trivial changes (31)
- apps/blog-nuxt/server/db/migrations/2026_06_19_202226_create_jobs_table.ts
- apps/blog-next/server/db/migrations/2026_06_19_202222_create_jobs_table.ts
- apps/blog-sveltekit/server/db/migrations/2026_04_25_044031_create_admins.ts
- apps/blog-nuxt/server/db/migrations/2026_04_25_044031_create_admins.ts
- apps/blog-nuxt/server/db/migrations/2026_04_25_044036_create_password_reset_tokens.ts
- apps/blog-sveltekit/server/db/migrations/2026_04_25_044034_create_auth_identities.ts
- apps/blog-next/server/db/migrations/2026_04_25_044034_create_auth_identities.ts
- apps/blog-nuxt/server/db/migrations/2026_04_25_044034_create_auth_identities.ts
- apps/blog-sveltekit/server/db/migrations/2026_04_25_044036_create_password_reset_tokens.ts
- apps/blog-next/server/db/migrations/2026_05_02_115334_create_comments_table.ts
- apps/blog-next/server/db/migrations/2026_04_25_044036_create_password_reset_tokens.ts
- apps/blog-nuxt/server/db/migrations/2026_04_25_044033_create_sessions.ts
- apps/blog-sveltekit/server/db/migrations/2026_04_25_044032_create_notifications.ts
- apps/blog-nuxt/server/db/migrations/2026_04_25_044032_create_notifications.ts
- apps/blog-next/server/db/migrations/2026_05_25_063242_create_cache_cache_table.ts
- apps/blog-sveltekit/server/db/migrations/2026_05_02_115430_create_comments_table.ts
- apps/blog-next/server/db/migrations/2026_04_25_044033_create_sessions.ts
- apps/blog-nuxt/server/db/migrations/2026_04_25_044037_create_email_verification_tokens.ts
- apps/blog-next/server/db/migrations/2026_04_25_044031_create_admins.ts
- apps/blog-next/server/db/migrations/2026_04_25_044035_create_personal_access_tokens.ts
- apps/blog-nuxt/server/db/migrations/2026_05_25_063246_create_cache_cache_table.ts
- apps/blog-sveltekit/server/db/migrations/2026_04_25_044032_create_users.ts
- apps/blog-sveltekit/server/db/migrations/2026_04_25_044037_create_email_verification_tokens.ts
- apps/blog-next/server/db/migrations/2026_04_25_044037_create_email_verification_tokens.ts
- apps/blog-next/server/db/migrations/2026_04_25_044032_create_users.ts
- apps/blog-nuxt/server/db/migrations/2026_05_02_115438_create_comments_table.ts
- apps/blog-sveltekit/server/db/migrations/2026_04_25_044035_create_personal_access_tokens.ts
- apps/blog-sveltekit/server/db/migrations/2026_04_25_044033_create_sessions.ts
- apps/blog-sveltekit/server/db/migrations/2026_05_25_063252_create_cache_cache_table.ts
- apps/blog-nuxt/server/db/migrations/2026_04_25_044032_create_users.ts
- packages/cli/src/project/scaffold/project-renderers.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- packages/queue/src/registry.ts
- apps/docs/docs/.vitepress/theme/components/Landing.vue
- packages/queue/src/contracts.ts
- apps/docs/docs/queue/jobs.md
✅ Deploy Preview for holo-docs canceled.
|
|
@CodeRabbit review |
✅ Action performedReview finished.
|
Summary by CodeRabbit
New Features
.dispatch().dispatch()and.dispatchSync()Documentation
Chores