negezor / vk-io

Modern VK API SDK for Node.js
https://npm.im/vk-io
MIT License
549 stars 85 forks source link

CollectError: Execute error #145

Closed SaLapus closed 5 years ago

SaLapus commented 5 years ago

What version of vk-io are you using?

4.0.0-rc.15

What version of Node.js are you using?

v10.15.0

What did you do?

function get_Post_from_Wall(offset)
{
    return new Promise
    (
        (resolve) =>
        {
            const collectStream = collect.wall.get(
            {
                owner_id: -147993117,
                offset,
                count: 1,
                                filter: "owner",
                                extended: true
            });

            collectStream.on('error', console.error);

            collectStream.on('data', async ({ total, percent, received, items }) =>
            {   // Information
                console.log('Total:', total);
                console.log('Percent:', percent);
                console.log('Received:', received);

                console.log('Items:', items);
                resolve(...);
            });

            collectStream.on('end', () =>
            {
                console.log('Data received\n\n');
            });
        }
    );
}

async function check_for_posts()
{
    await get_Post_from_Wall(1);
}

check_for_posts();

Простое получение записей со стены сообщества по одной.

What did you expect to happen?

count: <Number>,
  items:
   [ { id: <Number>,
       from_id: -<Number>,
       owner_id: -<Number>,
       date: <Number>,
       marked_as_ads: 0,
       post_type: <string>,
       text: <string>,
       copy_history: [Array],
       post_source: [Object],
       comments: [Object],
       likes: [Object],
       reposts: [Object],
       views: [Object],
       is_favorite: <boolean>} ],
  profiles: [],
  groups: [ { } ]

Без параметра extended все прекрасно работает, однако при подключении extended: true выдает ошибку. Необходимые права у приложения есть, метод vk.api.wall.get({}); работает в штатном режиме.

What was the actual result?

{ CollectError: Execute error
    at CollectStream._read (C:\bot\VK_Bot\node_modules\vk-io\lib\index.js:4280:28)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  code: 'EXECUTE_ERROR',
  name: 'CollectError',
  errors:
   [ { ExecuteError: Code №7 - Permission to perform this action is denied
         at request.resolve.errors.map.error (C:\bot\VK_Bot\node_modules\vk-io\lib\index.js:1131:62)
         at Array.map (<anonymous>)
         at API.callMethod (C:\bot\VK_Bot\node_modules\vk-io\lib\index.js:1131:49)
         at process._tickCallback (internal/process/next_tick.js:68:7) code: 7, name: 'ExecuteError', method: 'wall.get' },
     { ExecuteError: Code №7 - Permission to perform this action is denied
         at request.resolve.errors.map.error (C:\bot\VK_Bot\node_modules\vk-io\lib\index.js:1131:62)
         at Array.map (<anonymous>)
         at API.callMethod (C:\bot\VK_Bot\node_modules\vk-io\lib\index.js:1131:49)
         at process._tickCallback (internal/process/next_tick.js:68:7) code: 7, name: 'ExecuteError', method: 'execute' } ] }
negezor commented 5 years ago

Я думаю проблема связана с тем, что в collect обрабатывается через execute, значит проблема на стороне, ВКонтакте. Можно передать параметр parallelCount: 1, тем самым не будет использоваться execute. К тому же, CollectStream имеет оболочку для Promise.

const { items, profiles, groups } = await collect.wall.get({
   owner_id: -147993117,
   offset,
   filter: "owner",
   extended: 1,
   parallelCount: 1
});