Skip to content

[BUG] Lỗi khi typing. #261

@sandichhuu

Description

@sandichhuu

Khi đang chạy thì bị lỗi code 602 ở file này:
node_modules\zca-js\dist\utils.js.

Dò ra thì bị exception khi parse json ở đây:
node_modules\zca-js\dist\apis\listen.js

if (cmd == 602 && subCmd == 0) {
    const parsedData = (await decodeEventData(parsed, this.cipherKey)).data;
    const { actions } = parsedData;
    for (const action of actions) {
        const data = JSON.parse(`{${action.data}}`); // Lỗi ở dòng này
        if (action.act_type == "typing") {
            if (action.act == "typing") {
                const typingObject = new UserTyping(data);
                this.emit("typing", typingObject);
            }
            else if (action.act == "gtyping") {
                // 26/02/2025
                // For a group with only two people, Zalo doesn't send a typing event.
                const typingObject = new GroupTyping(data);
                this.emit("typing", typingObject);
            }
        }
    }
}

Log:

2026-01-24T08:13:03.450040661Z UNCAUGHT EXCEPTION: 301 |                 }
2026-01-24T08:13:03.450092892Z 302 |                 if (cmd == 602 && subCmd == 0) {
2026-01-24T08:13:03.450098894Z 303 |                     const parsedData = (await decodeEventData(parsed, this.cipherKey)).data;
2026-01-24T08:13:03.450103227Z 304 |                     const { actions } = parsedData;
2026-01-24T08:13:03.450107916Z 305 |                     for (const action of actions) {
2026-01-24T08:13:03.450111844Z 306 |                         const data = JSON.parse(`{${action.data}}`);
2026-01-24T08:13:03.450115654Z                                                 ^
2026-01-24T08:13:03.450119205Z SyntaxError: JSON Parse error: Expected '}'
2026-01-24T08:13:03.450122805Z       at  (/usr/src/app/node_modules/zca-js/dist/apis/listen.js:306:43)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions