* refactor: consolidate agent config folders into agents directory - Move .claude/skills and .claude/rules content to agents/ - Remove duplicate .cursor/ and .goose/ folders - Create symlinks from .claude/ and .cursor/ to agents/ - Convert review.mdc to quality-review-checklist.md with proper frontmatter Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * feat: add Cal.com APIv2 skills to agents directory Move the Cal.com API v2 skills from PR #27445 into the consolidated agents/skills/ directory structure. This includes: - SKILL.md - Main skill file with API overview - references/authentication.md - Authentication methods - references/bookings.md - Bookings API reference - references/calendars.md - Calendars API reference - references/event-types.md - Event types API reference - references/schedules.md - Schedules API reference - references/slots-availability.md - Slots and availability API reference - references/webhooks.md - Webhooks API reference Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * fix: update calcom-api skill to use Claude Code frontmatter format Remove non-standard frontmatter fields (license, metadata) and keep only the Claude Code supported fields (name, description) as per the Claude Code skills specification. Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * refactor: restructure calcom-api SKILL.md as index file Convert SKILL.md from a comprehensive API doc (317 lines) to a concise index file (108 lines) that references the detailed documentation in the references/ folder. This follows the Claude Code skills pattern of keeping SKILL.md focused with supporting files for detailed content. The SKILL.md now: - Provides a quick start guide with essential examples - References all 7 detailed reference docs in a table - Lists common workflows and best practices - Points to external resources Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * docs: preserve deleted content in reference files Move content that was removed from SKILL.md to appropriate reference files: - Add Error Handling and Pagination sections to authentication.md - Add Organization endpoints to event-types.md - Add Core Concepts section back to SKILL.md This ensures no useful API documentation is lost during the restructuring. Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
73 lines
1.9 KiB
Markdown
73 lines
1.9 KiB
Markdown
---
|
|
title: Use after() for Non-Blocking Operations
|
|
impact: MEDIUM
|
|
impactDescription: faster response times
|
|
tags: server, async, logging, analytics, side-effects
|
|
---
|
|
|
|
## Use after() for Non-Blocking Operations
|
|
|
|
Use Next.js's `after()` to schedule work that should execute after a response is sent. This prevents logging, analytics, and other side effects from blocking the response.
|
|
|
|
**Incorrect (blocks response):**
|
|
|
|
```tsx
|
|
import { logUserAction } from '@/app/utils'
|
|
|
|
export async function POST(request: Request) {
|
|
// Perform mutation
|
|
await updateDatabase(request)
|
|
|
|
// Logging blocks the response
|
|
const userAgent = request.headers.get('user-agent') || 'unknown'
|
|
await logUserAction({ userAgent })
|
|
|
|
return new Response(JSON.stringify({ status: 'success' }), {
|
|
status: 200,
|
|
headers: { 'Content-Type': 'application/json' }
|
|
})
|
|
}
|
|
```
|
|
|
|
**Correct (non-blocking):**
|
|
|
|
```tsx
|
|
import { after } from 'next/server'
|
|
import { headers } from 'next/headers'
|
|
import { logUserAction } from '@/app/utils'
|
|
|
|
export async function POST(request: Request) {
|
|
// Perform mutation
|
|
await updateDatabase(request)
|
|
|
|
// Log after response is sent
|
|
after(async () => {
|
|
const userAgent = (await headers()).get('user-agent') || 'unknown'
|
|
|
|
await logUserAction({ userAgent })
|
|
})
|
|
|
|
return new Response(JSON.stringify({ status: 'success' }), {
|
|
status: 200,
|
|
headers: { 'Content-Type': 'application/json' }
|
|
})
|
|
}
|
|
```
|
|
|
|
The response is sent immediately while logging happens in the background.
|
|
|
|
**Common use cases:**
|
|
|
|
- Analytics tracking
|
|
- Audit logging
|
|
- Sending notifications
|
|
- Cache invalidation
|
|
- Cleanup tasks
|
|
|
|
**Important notes:**
|
|
|
|
- `after()` runs even if the response fails or redirects
|
|
- Works in Server Actions, Route Handlers, and Server Components
|
|
|
|
Reference: [https://nextjs.org/docs/app/api-reference/functions/after](https://nextjs.org/docs/app/api-reference/functions/after)
|