@firebase/firestore 3.8.3-canary.d5d78cbcf → 3.8.3-canary.e2bf2eca2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ import { FirebaseError, getDefaultEmulatorHostnameAndPort, createMockUserToken,
6
6
  import nodeFetch from 'node-fetch';
7
7
  import { randomBytes as randomBytes$1 } from 'crypto';
8
8
 
9
- const version$1 = "3.8.3-canary.d5d78cbcf";
9
+ const version$1 = "3.8.3-canary.e2bf2eca2";
10
10
 
11
11
  /**
12
12
  * @license
@@ -59,7 +59,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
59
59
  User.FIRST_PARTY = new User('first-party-uid');
60
60
  User.MOCK_USER = new User('mock-user');
61
61
 
62
- const version = "9.17.1-canary.d5d78cbcf";
62
+ const version = "9.17.1-canary.e2bf2eca2";
63
63
 
64
64
  /**
65
65
  * @license
@@ -1177,6 +1177,66 @@ function validatePositiveNumber(functionName, n) {
1177
1177
  }
1178
1178
  }
1179
1179
 
1180
+ /**
1181
+ * @license
1182
+ * Copyright 2023 Google LLC
1183
+ *
1184
+ * Licensed under the Apache License, Version 2.0 (the "License");
1185
+ * you may not use this file except in compliance with the License.
1186
+ * You may obtain a copy of the License at
1187
+ *
1188
+ * http://www.apache.org/licenses/LICENSE-2.0
1189
+ *
1190
+ * Unless required by applicable law or agreed to in writing, software
1191
+ * distributed under the License is distributed on an "AS IS" BASIS,
1192
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1193
+ * See the License for the specific language governing permissions and
1194
+ * limitations under the License.
1195
+ */
1196
+ /**
1197
+ * The value returned from the most recent invocation of
1198
+ * `generateUniqueDebugId()`, or null if it has never been invoked.
1199
+ */
1200
+ let lastUniqueDebugId = null;
1201
+ /**
1202
+ * Generates and returns an initial value for `lastUniqueDebugId`.
1203
+ *
1204
+ * The returned value is randomly selected from a range of integers that are
1205
+ * represented as 8 hexadecimal digits. This means that (within reason) any
1206
+ * numbers generated by incrementing the returned number by 1 will also be
1207
+ * represented by 8 hexadecimal digits. This leads to all "IDs" having the same
1208
+ * length when converted to a hexadecimal string, making reading logs containing
1209
+ * these IDs easier to follow. And since the return value is randomly selected
1210
+ * it will help to differentiate between logs from different executions.
1211
+ */
1212
+ function generateInitialUniqueDebugId() {
1213
+ const minResult = 0x10000000;
1214
+ const maxResult = 0x90000000;
1215
+ const resultRange = maxResult - minResult;
1216
+ const resultOffset = Math.round(resultRange * Math.random());
1217
+ return minResult + resultOffset;
1218
+ }
1219
+ /**
1220
+ * Generates and returns a unique ID as a hexadecimal string.
1221
+ *
1222
+ * The returned ID is intended to be used in debug logging messages to help
1223
+ * correlate log messages that may be spatially separated in the logs, but
1224
+ * logically related. For example, a network connection could include the same
1225
+ * "debug ID" string in all of its log messages to help trace a specific
1226
+ * connection over time.
1227
+ *
1228
+ * @return the 10-character generated ID (e.g. "0xa1b2c3d4").
1229
+ */
1230
+ function generateUniqueDebugId() {
1231
+ if (lastUniqueDebugId === null) {
1232
+ lastUniqueDebugId = generateInitialUniqueDebugId();
1233
+ }
1234
+ else {
1235
+ lastUniqueDebugId++;
1236
+ }
1237
+ return '0x' + lastUniqueDebugId.toString(16);
1238
+ }
1239
+
1180
1240
  /**
1181
1241
  * @license
1182
1242
  * Copyright 2020 Google LLC
@@ -1233,15 +1293,16 @@ class RestConnection {
1233
1293
  return false;
1234
1294
  }
1235
1295
  invokeRPC(rpcName, path, req, authToken, appCheckToken) {
1296
+ const streamId = generateUniqueDebugId();
1236
1297
  const url = this.makeUrl(rpcName, path);
1237
- logDebug(LOG_TAG$3, 'Sending: ', url, req);
1298
+ logDebug(LOG_TAG$3, `Sending RPC '${rpcName}' ${streamId}:`, url, req);
1238
1299
  const headers = {};
1239
1300
  this.modifyHeadersForRequest(headers, authToken, appCheckToken);
1240
1301
  return this.performRPCRequest(rpcName, url, headers, req).then(response => {
1241
- logDebug(LOG_TAG$3, 'Received: ', response);
1302
+ logDebug(LOG_TAG$3, `Received RPC '${rpcName}' ${streamId}: `, response);
1242
1303
  return response;
1243
1304
  }, (err) => {
1244
- logWarn(LOG_TAG$3, `${rpcName} failed with error: `, err, 'url: ', url, 'request:', req);
1305
+ logWarn(LOG_TAG$3, `RPC '${rpcName}' ${streamId} failed with error: `, err, 'url: ', url, 'request:', req);
1245
1306
  throw err;
1246
1307
  });
1247
1308
  }