Skip to content

Commit

Permalink
fix: Increase process recurrence timeout (#9665)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch committed Apr 25, 2024
1 parent 42c432e commit f4e0cda
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
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

0 comments on commit f4e0cda

Please sign in to comment.