-
Notifications
You must be signed in to change notification settings - Fork 0
OUT-3065 | Resync files that are failed to upload #86
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| await resyncFailedFilesInAssembly.trigger({ | ||
| portalId, | ||
| failedSyncs: failedSyncsForPortal, | ||
| }) |
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.
Are we okay with all these jobs being run in parallel? Like, we won't get ratelimited by Assembly or Dbx side?
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.
The job is calling a service where bottleneck is applied for parallel processing. Also, there aren't much files that are failing, so its safe to let things pass for now.
| export const resyncFailedFiles = async (request: NextRequest) => { | ||
| const authHeader = request.headers.get('authorization') | ||
| if (authHeader !== `Bearer ${env.CRON_SECRET}`) { | ||
| throw new APIError('Unauthorized', 401) |
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.
Can we use httpStatus.UNAUTHORIZED here for consistency?
| }, | ||
| }) | ||
|
|
||
| export const resyncFailedFilesInAssembly = task({ |
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.
We should also consider defining machine here since single portal could have many files and can be long running as well. We have TRIGGER_MACHINE env that you can import from server.env.ts file and use that here.
|
|
||
| for (const portalId in failedSyncWorkspaceMap) { | ||
| const failedSyncsForPortal = failedSyncWorkspaceMap[portalId] | ||
| await resyncFailedFilesInAssembly.trigger({ |
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.
If the intention is to await for the trigger task here, it won't work. This is the nature of the task unless we do triggerAndWait which can only be done from another trigger task.
Changes