Loading products using process function does not stop
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, nodejs
- Lĩnh vực
- api
Hướng nghiên cứu
Bắt đầu từ entry point products.perPage(PER_PAGE).process(...) được hiển thị trong phần tái hiện và theo dõi cách các batch được yêu cầu sau khi process callback thay đổi res.body.results. Tái hiện với số lượng sản phẩm đã nêu và việc xóa item.id; được xem là hoàn tất khi quá trình xử lý dừng lại sau tất cả sản phẩm và completion handler cuối cùng chạy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Expected behavior
Function sphere.products.perPage(50).process(function process(res){}) should load products in batches and send them to process function.
Actual behavior
If I add this code to process function, loading will never stop.
var list = res.body.results;
list = list.map(function (item) {
delete item.id; // when commented out - loading works as expected
return item;
});
Steps to reproduce the behavior
I was testing it on:
- project with 639 products and perPage = 50
- project with 1 product and perPage = 1
It looks like it occurs when perPage <= productCount
Here is full code which gives me an error.
var _ = require('lodash');
var Promise = require('bluebird');
var Sphere = require('sphere-node-sdk');
var SphereUtils = require('sphere-node-utils');
var SphereClient = Sphere.SphereClient;
var ProjectCredentialsConfig = SphereUtils.ProjectCredentialsConfig;
var sourceCredentials, sourceClient;
var PER_PAGE = 50;
var projectKey = "<product-key>";
var total = 0;
console.log('>> Loading products from %s', projectKey);
ProjectCredentialsConfig.create()
.then(function (credentials) {
sourceCredentials = credentials.enrichCredentials({project_key: projectKey});
sourceClient = new SphereClient({config: sourceCredentials});
console.log("Loading per page %d", PER_PAGE);
var total = 0;
return sourceClient.products
.perPage(PER_PAGE)
.process(function(res) {
var list = res.body.results;
total += list.length;
console.log('Loaded %d / totally %d', list.length, total);
list = list.map(function (item) {
delete item.id; // when commented out - loading works as expected
return item;
});
return Promise.resolve();
})
})
.then(function() {
console.log("Finished - total %d", total);
})
.catch(function (err) {
console.error("Final error:", err.stack || err);
});
- Ngôn ngữ chính
- CoffeeScript
- Star
- 16
- Fork
- 8
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của commercetools/sphere-node-sdk
-
Type: Enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 52/100
commercetools/sphere-node-sdk#346 ·
-
Response from CTP could be emptyĐang mởType: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
commercetools/sphere-node-sdk#309 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 35/100
commercetools/sphere-node-sdk#252 · 1 bình luận · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 38/100
commercetools/sphere-node-sdk#215 · 4 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
commercetools/sphere-node-sdk#184 ·
Tất cả issue của commercetools/sphere-node-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
langchain-ai/deepagentsjs#898 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug documentation P2 UI/UX
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
BasedHardware/omi#20084 ·
Maintainer thường phản hồi trong vòng 1 ngày