diff --git a/deno-runtime/handlers/slashcommand-handler.ts b/deno-runtime/handlers/slashcommand-handler.ts index 5422e1e58..5415094e3 100644 --- a/deno-runtime/handlers/slashcommand-handler.ts +++ b/deno-runtime/handlers/slashcommand-handler.ts @@ -2,8 +2,8 @@ import { Defined, JsonRpcError } from 'jsonrpc-lite'; import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms/IRoom.ts'; import type { ISlashCommand } from '@rocket.chat/apps-engine/definition/slashcommands/ISlashCommand.ts'; -import { SlashCommandContext as _SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands/SlashCommandContext.ts'; -import { Room as _Room } from '@rocket.chat/apps-engine/server/rooms/Room.ts'; +import type { SlashCommandContext as _SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands/SlashCommandContext.ts'; +import type { Room as _Room } from '@rocket.chat/apps-engine/server/rooms/Room.ts'; import { AppObjectRegistry } from '../AppObjectRegistry.ts'; import { AppAccessors, AppAccessorsInstance } from '../lib/accessors/mod.ts'; diff --git a/deno-runtime/lib/messenger.ts b/deno-runtime/lib/messenger.ts index 8ce558da3..c701cce5e 100644 --- a/deno-runtime/lib/messenger.ts +++ b/deno-runtime/lib/messenger.ts @@ -125,10 +125,8 @@ export async function successResponse({ id, result }: SuccessResponseDescriptor) export async function sendRequest(requestDescriptor: RequestDescriptor): Promise { const request = jsonrpc.request(Math.random().toString(36).slice(2), requestDescriptor.method, requestDescriptor.params); - await Transport.send(request); - // TODO: add timeout to this - return new Promise((resolve, reject) => { + const responsePromise = new Promise((resolve, reject) => { const handler = (event: Event) => { if (event instanceof ErrorEvent) { reject(event.error); @@ -143,6 +141,10 @@ export async function sendRequest(requestDescriptor: RequestDescriptor): Promise RPCResponseObserver.addEventListener(`response:${request.id}`, handler); }); + + await Transport.send(request); + + return responsePromise as Promise; } export function sendNotification({ method, params }: NotificationDescriptor) {