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

Notifier typing causes error #802

Open
nbak opened this issue Sep 17, 2024 · 1 comment
Open

Notifier typing causes error #802

nbak opened this issue Sep 17, 2024 · 1 comment

Comments

@nbak
Copy link

nbak commented Sep 17, 2024

App implements IPostMessageSent.
Permissions listed in app.json: networking, message.write, persistence, slashcommand

executePostMessageSent
async executePostMessageSent(message: IMessage, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify): Promise<void> {
    console.log(1);
    let stopTyping: (() => Promise<void>) | null = null;
    try {
        const appUser = (await read.getUserReader().getAppUser())!;
        console.log(2);
        stopTyping = await modify.getNotifier().typing({
            id: message.room.id,
            scope: TypingScope.Room,
            username: appUser.name,
        });
        console.log(3);
        await sleep(2000); // Custom sleep funciton
        console.log(4);
    } catch (e) {
        console.log(5);
    } finally {
        console.log(6);
        await stopTyping?.();
        console.log(7);
    }
}

Application log after message sent in chat

Subprocess stderr 1
Subprocess stderr 2
Subprocess stderr error: Uncaught (in promise) TypeError: Cannot create property 'logs' on string 'Result must exist for success Response objects'
        data.logs = logger.getLogs();
                 ^
    at Module.errorResponse (file:///app/bundle/programs/server/npm/node_modules/@rocket.chat/apps-engine/deno-runtime/lib/messenger.ts:141:18)
    at main (file:///app/bundle/programs/server/npm/node_modules/@rocket.chat/apps-engine/deno-runtime/main.ts:121:33)
    at eventLoopTick (ext:core/01_core.js:183:11)

Using this.getLogger().log instead of console.log leaves no logs saved/printed.
Calling modify.getNotifier().notifyUser in slash command works without errors.

Message Result must exist for success Response objects seems to be from jsonrpc-lite, called from this line.

Apps Engine version: 1.45.0

Issue present in Rocket.Chat versions 6.10.x, 6.11.x, 6.12.0, 6.12.1.
In Rocket.Chat version 6.9.5 app works without errors.

@cuonghuunguyen
Copy link
Contributor

Got the same issue on Rocket.Chat 6.12.1

Subprocess stderr error: Uncaught (in promise) TypeError: Cannot create property 'logs' on string 'Result must exist for success Response objects'
        data.logs = logger.getLogs();
                 ^
    at Module.errorResponse (file:///app/bundle/programs/server/npm/node_modules/@rocket.chat/apps-engine/deno-runtime/lib/messenger.ts:141:18)
    at main (file:///app/bundle/programs/server/npm/node_modules/@rocket.chat/apps-engine/deno-runtime/main.ts:121:33)
    at eventLoopTick (ext:core/01_core.js:183:11)
    ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants