Когда пользователь входит в мое приложение, я хочу отправить начальные данные (например, список контактов пользователя) в бэкэнд для обработки создания пользователя.Поскольку это долгая работа, я решил разбить ее на отдельные вызовы HTTP.
Для простоты, вот запрос на стороне приложения:
for (int i = 0; i < 3; ++i) {
data.put("val", String.valueOf(i));
firebaseFunctions.getHttpsCallable("sandbox").call(data)
.addOnFailureListener(e -> Log.e("Error; " + e.getMessage()))
.addOnSuccessListener(result -> Log.v("Success! Got " + result.getData()));
}
и функция HTTPs (в Node.js):
exports.sandbox = functions.https.onCall((data, context) => {
console.log("In, data.val is " + data.val);
});
Если я вызываю функцию через оболочку firebase functions:shell
следующим образом:
for (let i = 0; i < 3; ++i) {
sandbox.post('').json({"data": {"val": "" + i}});
}
, я получаю вывод:
In, data.val is 0
In, data.val is 1
In, data.val is 2
Но если код приложения запускается, консоль Firebase показывает следующий журнал:
2018-05-16T10:09:02.080247334Z D sandbox: Function execution started
2018-05-16T10:09:02.080333313Z D sandbox: Billing account not configured.
External network is not accessible and quotas are severely limited.
Configure billing account to remove these restrictions
2018-05-16T10:09:03.051Z I sandbox: In, data.val is 2
2018-05-16T10:09:03.135023272Z D sandbox: Function execution took 1056 ms, finished with status code: 200
2018-05-16T10:09:04.073804790Z D sandbox: Function execution started
2018-05-16T10:09:04.073930247Z D sandbox: Billing account not configured.
External network is not accessible and quotas are severely limited.
Configure billing account to remove these restrictions
2018-05-16T10:09:04.236Z I sandbox: In, data.val is 2
2018-05-16T10:09:04.239244077Z D sandbox: Function execution took 166 ms, finished with status code: 200
2018-05-16T10:09:06.722270621Z D sandbox: Function execution started
2018-05-16T10:09:06.722387172Z D sandbox: Billing account not configured.
External network is not accessible and quotas are severely limited.
Configure billing account to remove these restrictions
2018-05-16T10:09:09.963Z I sandbox: In, data.val is 2
2018-05-16T10:09:09.971406186Z D sandbox: Function execution took 3250 ms, finished with status code: 200
Я вижу In, data.val is 2
три раза.Что происходит?