{"record":{"id":"3f109af45df9f27b","repo":"RocketChat/Rocket.Chat","slug":"failed-to-create-direct-call","errorCode":null,"errorMessage":"failed-to-create-direct-call","messagePattern":"failed-to-create-direct-call","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/services/video-conference/service.ts","lineNumber":759,"sourceCode":"\n\t\tconst callId = await VideoConferenceModel.createDirect({\n\t\t\t...extraData,\n\t\t\trid,\n\t\t\tcreatedBy: {\n\t\t\t\t_id: user._id,\n\t\t\t\tname: user.name as string,\n\t\t\t\tusername: user.username as string,\n\t\t\t},\n\t\t\tproviderName,\n\t\t});\n\n\t\tawait this.runNewVideoConferenceEvent(callId);\n\n\t\tawait this.maybeCreateDiscussion(callId, user);\n\n\t\tconst call = (await this.getUnfiltered(callId)) as IDirectVideoConference | null;\n\t\tif (!call) {\n\t\t\tthrow new Error('failed-to-create-direct-call');\n\t\t}\n\t\tconst url = await this.generateNewUrl(call);\n\t\tawait VideoConferenceModel.setUrlById(callId, url);\n\n\t\tconst messageId = await this.createMessage(call, user);\n\t\tcall.messages.started = messageId;\n\t\tawait VideoConferenceModel.setMessageById(callId, 'started', messageId);\n\n\t\t// After 40 seconds if the status is still \"calling\", we cancel the call automatically.\n\t\tsetTimeout(async () => {\n\t\t\ttry {\n\t\t\t\tconst call = await VideoConferenceModel.findOneById<IDirectVideoConference>(callId);\n\n\t\t\t\tif (call) {\n\t\t\t\t\tawait this.endDirectCall(call);\n\t\t\t\t\tif (call.status !== VideoConferenceStatus.CALLING) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/services/video-conference/service.ts#L741-L777","documentation":"Thrown by startDirect() after the call document was created, the onNewVideoConference app event fired and maybeCreateDiscussion ran: getUnfiltered(callId) returns null. getUnfiltered bypasses room/user visibility filters, so null means the video_conference record itself is gone - typically a provider app handler deleted or moved it during runNewVideoConferenceEvent, a model hook removed it, or read-after-write inconsistency in the database.","triggerScenarios":"A provider app's new-conference handler removes or recreates the call doc during creation; a DB observer/hook deletes it; in replica-set deployments the read routes to a secondary that has not yet applied the insert.","commonSituations":"Custom provider apps that 'clean up' calls they do not recognize; app versions whose handlers reject unconfigured providers; local dev against a lagging mongod replica set.","solutions":["Inspect installed apps' onNewVideoConference handlers for deletion/recreation logic and fix or remove the offending app","Check the video_conference collection to confirm the doc exists right after create (distinguishes deletion from failed insert)","If using a replica set, ensure reads for this path hit the primary or tolerate replication lag","Retry the start call once - transient races resolve on a second attempt"],"exampleFix":"// before\nconst call = await getUnfiltered(callId);\nif (!call) throw new Error('failed-to-create-direct-call');\n\n// after\nlet call = await getUnfiltered(callId);\nif (!call) {\n\tawait new Promise((r) => setTimeout(r, 100));\n\tcall = await getUnfiltered(callId); // tolerate replication lag / handler rewrite\n}\nif (!call) throw new Error('failed-to-create-direct-call');","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n\tawait videoConfService.startCall(user, { _id: rid, uids });\n} catch (err) {\n\tif (err instanceof Error && err.message === 'failed-to-create-direct-call') {\n\t\t// log callId context, inspect provider app handlers, then surface a retry to the user\n\t}\n}","preventionTips":["Audit provider apps' onNewVideoConference handlers for deletion or recreation of call docs","Keep the video_conference write/read path on the primary in replica-set deployments","Log the created callId immediately so a vanished doc is traceable"],"tags":["video-conference","database-consistency","apps-engine","race-condition"],"backgroundTag":"created-record-not-found","analyzedSha":"e4b8178b205510181a96ceefee043d0abcd13e5a","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}