Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ yarn-error.log*
# vercel
.vercel

# trigger.dev
.trigger

# typescript
*.tsbuildinfo
next-env.d.ts
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"version": "0.1.0",
"scripts": {
"dev": "next dev --turbopack",
"trigger:dev": "npx trigger.dev@4.4.4 dev",
"trigger:deploy": "npx trigger.dev@4.4.4 deploy",
"build": "next build --turbopack",
"build:all": "sh scripts/build/build.sh",
"start": "next start",
Expand All @@ -21,7 +23,10 @@
},
"dependencies": {
"@assembly-js/node-sdk": "^4.2.2",
"@sentry/esbuild-plugin": "^4.6.1",
"@sentry/nextjs": "^10.29.0",
"@trigger.dev/build": "4.4.4",
"@trigger.dev/sdk": "4.4.4",
"@types/deep-equal": "^1.0.4",
"@types/html-to-text": "^9.0.4",
"bottleneck": "^2.19.5",
Expand Down
1,073 changes: 1,063 additions & 10 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions src/app/cron/retry-failed-syncs/route.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/config/server.env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ const ServerEnvSchema = z.object({
// Flags
FLAG_DISABLE_NOTIFICATION_EMAILS: z.coerce.boolean().default(false),
FLAG_ENABLE_DELETE_SYNC: z.coerce.boolean().default(false),

// CRON
CRON_SECRET: z.string().optional(),
})

// Collapse the precedence once here, matching the SDK's getEnvMode
Expand Down
19 changes: 0 additions & 19 deletions src/features/failed-syncs/api/failedSyncs.controller.ts

This file was deleted.

12 changes: 12 additions & 0 deletions src/trigger/resyncFailedRecords.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import RetryFailedSyncsService from '@failed-syncs/lib/RetryFailedSyncs.service'
import { schedules } from '@trigger.dev/sdk'

// Runs every 8 hours on trigger.dev's own scheduler (no Vercel cron / route).
export const processResyncForFailedRecords = schedules.task({
id: 'process-resync-for-failed-records',
cron: '0 */8 * * *',
machine: 'small-2x',
run: async () => {
await new RetryFailedSyncsService().retryFailedSyncs()
},
})
85 changes: 85 additions & 0 deletions trigger.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { sentryEsbuildPlugin } from '@sentry/esbuild-plugin'
import * as Sentry from '@sentry/nextjs'
import { esbuildPlugin } from '@trigger.dev/build/extensions'
import { defineConfig } from '@trigger.dev/sdk/v3'
import dotenv from 'dotenv'
import { z } from 'zod'

dotenv.config()

const vercelEnv = process.env.VERCEL_ENV
const isProd = vercelEnv === 'production'
const project = z.string().min(1).parse(process.env.TRIGGER_PROJECT_ID)
const org = isProd ? z.string().min(1).parse(process.env.SENTRY_ORG) : ''
const sentryProject = isProd ? z.string().min(1).parse(process.env.SENTRY_PROJECT) : ''
const sentryAuthToken = isProd ? z.string().min(1).parse(process.env.SENTRY_AUTH_TOKEN) : ''
const dsn = isProd ? z.string().min(1).parse(process.env.NEXT_PUBLIC_SENTRY_DSN) : ''

export default defineConfig({
project,
runtime: 'node',
logLevel: 'log',
// The max compute seconds a task is allowed to run. If the task run exceeds this duration, it will be stopped.
// You can override this on an individual task.
// See https://trigger.dev/docs/runs/max-duration
maxDuration: 3600,
retries: {
enabledInDev: true,
default: {
maxAttempts: 3,
minTimeoutInMs: 1000,
maxTimeoutInMs: 10000,
factor: 2,
randomize: true,
},
},
dirs: ['./src/trigger'],
build: {
extensions: [
// `server-only` throws unless bundled under Next's `react-server` condition.
// trigger.dev bundles with esbuild and runs in plain Node, so we stub the
// marker to an empty module. The modules it guards are real server code that
// we do want running inside the trigger worker.
esbuildPlugin({
name: 'stub-server-only',
setup(build) {
build.onResolve({ filter: /^server-only$/ }, (args) => ({
path: args.path,
namespace: 'server-only-stub',
}))
build.onLoad({ filter: /.*/, namespace: 'server-only-stub' }, () => ({
contents: '',
loader: 'js',
}))
},
}),
esbuildPlugin(
sentryEsbuildPlugin({
org,
project: sentryProject,
// Find this auth token in settings -> developer settings -> auth tokens
authToken: sentryAuthToken,
}),
{ placement: 'last', target: 'deploy' },
),
],
},
init: () => {
Sentry.init({
defaultIntegrations: false,
// The Data Source Name (DSN) is a unique identifier for your Sentry project.
dsn,
// Update this to match the environment you want to track errors for
environment: vercelEnv,
})
},
onFailure: ({ payload, error, ctx }) => {
console.error({ payload, error, ctx })
Sentry.captureException(error, {
extra: {
payload,
ctx,
},
})
},
})
8 changes: 1 addition & 7 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"crons": [
{
"path": "/cron/retry-failed-syncs",
"schedule": "0 */2 * * *"
}
]
"$schema": "https://openapi.vercel.sh/vercel.json"
}
Loading