agentejo / cockpit

Add content management functionality to any site - plug & play / headless / api-first CMS
http://getcockpit.com
MIT License
5.4k stars 524 forks source link

Importing (large amounts of data) with collection links stalls #1422

Closed eternalflamez closed 3 years ago

eternalflamez commented 3 years ago

This is due to this findOne call not actually resolving on error, adding a .catch to this block would solve the issue:

https://github.com/agentejo/cockpit/blob/49233716d28571f771655a732640c8895f15736a/modules/Collections/assets/import/filter.js#L131

eternalflamez commented 3 years ago

For instance:

App.callmodule('collections:findOne', [field.options.link, filter]).then(function(data) {

if (data.result && data.result._id) {
    //TODO add support for multiple imports
    var entry = {_id:data.result._id, display: data.result[field.options.display] || data.result[Filter.collections[field.options.link].fields[0].name] || 'n/a'};
    $this.resolve(field.options.multiple ? [entry]:entry);

} else {
    console.log("Couldn't find a collection reference for "+value);
    $this.resolve(null);
}
})
.catch(() => {
    console.log("Couldn't find a collection reference for "+value);
    $this.resolve(null);
});