Skip to content
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

fix: Increase process recurrence timeout #9665

Merged
merged 1 commit into from
Apr 25, 2024
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
16 changes: 8 additions & 8 deletions packages/chronos/chronos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ const chronos = () => {
processRecurrence: {
onTick: () => {
const query = `
mutation ProcessRecurrence{
processRecurrence{
... on ProcessRecurrenceSuccess {
meetingsStarted
meetingsEnded
mutation ProcessRecurrence {
processRecurrence{
... on ProcessRecurrenceSuccess {
meetingsStarted
meetingsEnded
}
}
}
}
`
publishWebhookGQL(query, {})
`
publishWebhookGQL(query, {}, {longRunning: true})
},
cronTime: CHRONOS_PROCESS_RECURRENCE
}
Expand Down
6 changes: 4 additions & 2 deletions packages/server/utils/PubSubPromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import numToBase64 from './numToBase64'
import sendToSentry from './sendToSentry'

const STANDARD_TIMEOUT = ms('10s')
const LONG_TIMEOUT = ms('60s')
const ADHOC_TIMEOUT = ms('10m')

interface Job {
Expand All @@ -17,6 +18,7 @@ const {SERVER_ID} = process.env
interface BaseRequest {
executorServerId?: string
isAdHoc?: boolean
longRunning?: boolean
}

export default class PubSubPromise<Request extends BaseRequest, Response> {
Expand Down Expand Up @@ -51,8 +53,8 @@ export default class PubSubPromise<Request extends BaseRequest, Response> {
return new Promise<Response>((resolve, reject) => {
const nextJob = numToBase64(this.jobCounter++)
const jobId = `${SERVER_ID}:${nextJob}`
const {isAdHoc} = request
const timeout = isAdHoc ? ADHOC_TIMEOUT : STANDARD_TIMEOUT
const {isAdHoc, longRunning} = request
const timeout = isAdHoc ? ADHOC_TIMEOUT : longRunning ? LONG_TIMEOUT : STANDARD_TIMEOUT
const timeoutId = setTimeout(() => {
delete this.jobs[jobId]
reject(new Error('TIMEOUT'))
Expand Down
9 changes: 7 additions & 2 deletions packages/server/utils/publishWebhookGQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import ServerAuthToken from '../database/types/ServerAuthToken'
import getGraphQLExecutor from './getGraphQLExecutor'
import sendToSentry from './sendToSentry'

const publishWebhookGQL = async (query: string, variables: Variables) => {
interface PublishOptions {
longRunning?: boolean
}

const publishWebhookGQL = async (query: string, variables: Variables, options?: PublishOptions) => {
try {
return await getGraphQLExecutor().publish({
authToken: new ServerAuthToken(),
query,
variables,
isPrivate: true
isPrivate: true,
...options
})
} catch (e) {
const error = e instanceof Error ? e : new Error('GQL executor failed to publish')
Expand Down
Loading