question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR: xmlobj.CommonPrefixes.forEach is not a function

See original GitHub issue

minio version:^7.0.17


found this problem when I used the listobjects API

1、When the third parameter recursive of listobjects is set to true, the result returned is correct

// code
const bucketName = params.bucketName || '';
const prefix = params.prefix || '';
const stream = app.minio.listObjects(bucketName, prefix, true);
return new Promise(resolve => {
    const res = [];
    stream.on('data', obj => {
        res.push(obj);
    });
    stream.on('end', () => {
        resolve({
            code: 0,
            data: res,
        });
    });
    stream.on('error', err => {
        resolve({
            code: 1,
            msg: err,
        });
    });
});

// result
[
    {
        "name":"child/aa.txt",
        "lastModified":"2020-12-01T04:04:18.148Z",
        "etag":"166bcae2d953f92b1fa3b40d218d2a38",
        "size":57
    },
    {
        "name":"bb.jpg",
        "lastModified":"2020-12-01T02:39:41.026Z",
        "etag":"ba02b3771a3ceeaf1d4925c62d05780b",
        "size":8730
    },
    {
        "name":"cc.jpg",
        "lastModified":"2020-12-01T02:40:21.905Z",
        "etag":"aed69181e64900aeaaf4b18798c7bcc4",
        "size":10891
    }
]

2、However, when the third parameter recursive is set to false, an error is reported

// code
app.minio.listObjects(bucketName, prefix, false);
......

// result
ERROR: xmlobj.CommonPrefixes.forEach is not a function

I entered the wrong node_ modules\minio\dist\main\xml- parsers.js:381 : 27 files, printing xmlobj.CommonPrefixes The results are as follows:

// Error source code
if (xmlobj.CommonPrefixes) {
    console.log('xmlobj.CommonPrefixes', xmlobj.CommonPrefixes);
    xmlobj.CommonPrefixes.forEach(function (commonPrefix) {
        var prefix = commonPrefix.Prefix[0];
        var size = 0;
        result.objects.push({
            prefix,
            size
        });
    });
}

// console.log result
xmlobj.CommonPrefixes { Prefix: 'child/' }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
raynaldilalangcommented, Jul 14, 2021

@mitni455 i just had the same issue, and avoided the error using listObjectsV2

0reactions
ebozdumancommented, Jun 9, 2021

Thank you @mitni455 for the information. Thank you @prakashsvmx for replying. This fix and quite some API support changes are on the way to be released. Please stay tuned.

Read more comments on GitHub >

github_iconTop Results From Across the Web

forEach is not a function error with JavaScript array
First option: invoke forEach indirectly. The parent.children is an Array like object. Use the following solution: const parent = this.el.
Read more >
Fix Uncaught TypeError: forEach is not a function Error in ...
The JavaScript "forEach is not a function" error occurs when you call the method 'forEach()' on a variable or property that's not of...
Read more >
minio - Bountysource
Hi guys, I get a very strange error every time I call the statObject method of the ... forEach is not a function...
Read more >
Viewing online file analysis results for 'mongodumpxp.exe'
Name Ordinal Address ??0Arg@pcrecpp@@QAE@PAD@Z #1 0x479fc0 ??0Arg@pcrecpp@@QAE@PADP6A_NPBDHPAX@Z@Z #2 0x47a0e0 ??0Arg@pcrecpp@@QAE@PAE@Z #3 0x479fc0
Read more >
vocab.txt - Hugging Face
... read ##roup ##ple has check elif ##ory ##ib ##ger ##ersion function end ... provid ##cket ##pace dep descri ##not bin ph callback...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found