-
Notifications
You must be signed in to change notification settings - Fork 3.3k
v0.4.13: bugfixes for dev containers, posthog redirect, helm updates #1621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
* fix(kb): added tiktoken for embedding token estimation * added missing mock
* feat(helm): added pdb to helm * add additional config
* feat(helm): added cert-postgresql template to helm * use js-tiktoken (pure js) in favor of tiktoken (wasm)
* fix(schedules): add cron job auth like other cron routes * migrate schedules to trigger dev * remove executions check * fix tests
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
This PR consolidates 7 bug fixes and feature additions across infrastructure, performance, and developer tooling:
Major Changes:
- Schedule execution migration to trigger.dev: Refactored schedule execution from monolithic API route to task-based architecture with
executeScheduleJobfunction, adding proper authentication viaverifyCronAuthand supporting both trigger.dev and direct execution modes - Token-aware embedding batching: Replaced fixed 50-item batching with accurate token counting using tiktoken library, batching by 8000 tokens for more efficient API usage and preventing request failures
- PostHog optimization: Disabled heavy features (pageleave, performance tracking, heatmaps, dead clicks) and narrowed autocapture scope; prevented redirect loops by excluding
/ingestpath from domain redirects - DevContainer improvements: Complete rewrite with proper docker-compose setup, non-root user configuration, automated dependency installation and database migrations
- Helm enhancements: Added PodDisruptionBudget for high availability and PostgreSQL TLS certificate template for secure connections
- SDK publishing fix: Upgraded Node.js to v22 in CI workflow to support
Filetype
Key Improvements:
- Better separation of concerns with schedule execution logic extracted to dedicated background task file
- More accurate token counting prevents API errors and optimizes costs
- Reduced PostHog overhead and eliminated redirect issues
- Production-ready Kubernetes configurations for availability and security
Confidence Score: 4/5
- This PR is safe to merge with minimal risk - changes are well-isolated, focused bug fixes with one minor concern around error handling.
- The PR demonstrates solid engineering practices with good separation of concerns, comprehensive error handling, and appropriate testing. The schedule execution refactoring properly extracts complex logic, the tiktoken integration uses established libraries correctly, and infrastructure changes follow Kubernetes best practices. Score is 4/5 rather than 5/5 due to one observation: the direct execution path uses fire-and-forget pattern (void executeScheduleJob) which could mask failures, though this appears intentional for the fallback mode.
- No files require special attention - all changes are straightforward and well-implemented
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/api/schedules/execute/route.ts | 4/5 | Refactored to delegate schedule execution to trigger.dev tasks or direct execution via executeScheduleJob. Added verifyCronAuth check for security. |
| apps/sim/background/schedule-execution.ts | 4/5 | New file containing extracted schedule execution logic with comprehensive error handling, rate limiting, usage checks, and trigger.dev integration. |
| apps/sim/lib/tokenization/estimators.ts | 5/5 | Added tiktoken integration for accurate token counting with OpenAI models, including batching utilities and truncation functions. |
| apps/sim/lib/embeddings/utils.ts | 5/5 | Migrated from fixed-size batching (50 items) to token-aware batching (8000 tokens) using tiktoken for more efficient API usage. |
| apps/sim/lib/posthog/provider.tsx | 5/5 | Reduced PostHog feature set (disabled pageleave, performance tracking, heatmaps, dead clicks) and narrowed autocapture scope to improve performance. |
| apps/sim/next.config.ts | 5/5 | Added /ingest path to redirect exclusions to prevent PostHog analytics calls from being redirected to sim.ai domain. |
| .devcontainer/post-create.sh | 5/5 | Comprehensive setup script that handles dependency installation, database migrations, and shell configuration for development environment. |
| .github/workflows/publish-ts-sdk.yml | 5/5 | Updated Node.js version from earlier version to 22 to support File type used in SDK. |
| helm/sim/templates/poddisruptionbudget.yaml | 5/5 | New PodDisruptionBudget template for both app and realtime services to ensure high availability during cluster operations. |
| helm/sim/templates/certificate-postgresql.yaml | 5/5 | New certificate template for PostgreSQL TLS with cert-manager integration for secure database connections. |
Sequence Diagram
sequenceDiagram
participant Cron as Cron Job
participant API as /api/schedules/execute
participant TriggerDev as Trigger.dev
participant Executor as Schedule Execution
participant DB as Database
participant RateLimit as Rate Limiter
participant Billing as Billing Service
participant Workflow as Workflow Executor
Cron->>API: GET (scheduled trigger)
API->>API: verifyCronAuth()
API->>DB: Query due schedules
DB-->>API: Return schedules list
alt TRIGGER_DEV_ENABLED
loop For each schedule
API->>TriggerDev: tasks.trigger('schedule-execution', payload)
TriggerDev-->>API: Task handle
end
API-->>Cron: 200 OK (queued)
TriggerDev->>Executor: executeScheduleJob(payload)
Executor->>DB: Load workflow & user data
Executor->>RateLimit: Check rate limits
Executor->>Billing: Check usage limits
alt Limits OK
Executor->>Workflow: Execute workflow
Workflow-->>Executor: Execution result
Executor->>DB: Update schedule (nextRunAt, lastRanAt)
Executor->>DB: Update user stats
else Rate limited
Executor->>DB: Set nextRunAt (retry in 5 min)
else Usage exceeded
Executor->>DB: Calculate and set nextRunAt
end
else Direct execution
loop For each schedule
API->>Executor: executeScheduleJob(payload)
Note over API,Executor: Fire and forget (void)
end
API-->>Cron: 200 OK (queued)
end
30 files reviewed, no comments
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.
Summary
fix(devcontainer): fixed devcontainers (#1614)
fix(posthog): prevent redirects by whitelisting ingest route (#1615)
fix(kb): added tiktoken for embedding token estimation (#1616)
feat(helm): added pdb to helm (#1617)
fix(schedules): migrate to trigger dev (#1618)
fix(sdk): fixed TS SDK publishing job to use later Node version (#1619)
feat(helm): added cert-postgresql template to helm (#1620)