Skip to content

Commit 888b3b5

Browse files
committed
Remove logs in prod
1 parent 990cadb commit 888b3b5

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

packages/hub/src/utils/XetBlob.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ interface ChunkHeader {
7777

7878
const CHUNK_HEADER_BYTES = 8;
7979

80+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
81+
const debug = (...args: unknown[]) => {};
82+
8083
/**
8184
* XetBlob is a blob implementation that fetches data directly from the Xet storage
8285
*/
@@ -150,7 +153,7 @@ export class XetBlob extends Blob {
150153
this.#reconstructionInfoPromise = (async () => {
151154
const connParams = await getAccessToken(this.repoId, this.accessToken, this.fetch, this.hubUrl);
152155

153-
// console.log(
156+
// debug(
154157
// `curl '${connParams.casUrl}/reconstruction/${this.hash}' -H 'Authorization: Bearer ${connParams.accessToken}'`
155158
// );
156159

@@ -217,15 +220,15 @@ export class XetBlob extends Blob {
217220
const termRanges = rangeList.getRanges(term.range.start, term.range.end);
218221

219222
if (termRanges.every((range) => range.data)) {
220-
console.log("all data available for term", term.hash, readBytesToSkip);
223+
debug("all data available for term", term.hash, readBytesToSkip);
221224
rangeLoop: for (const range of termRanges) {
222225
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
223226
for (let chunk of range.data!) {
224227
if (chunk.length > maxBytes - totalBytesRead) {
225228
chunk = chunk.slice(0, maxBytes - totalBytesRead);
226229
}
227230
totalBytesRead += chunk.length;
228-
console.log("yield", chunk.length, "bytes", "total read", totalBytesRead);
231+
debug("yield", chunk.length, "bytes", "total read", totalBytesRead);
229232
// The stream consumer can decide to transfer ownership of the chunk, so we need to return a clone
230233
// if there's more than one range for the same term
231234
yield range.refCount > 1 ? chunk.slice() : chunk;
@@ -250,9 +253,9 @@ export class XetBlob extends Blob {
250253
);
251254
}
252255

253-
console.log("term", term);
254-
console.log("fetchinfo", fetchInfo);
255-
console.log("readBytesToSkip", readBytesToSkip);
256+
debug("term", term);
257+
debug("fetchinfo", fetchInfo);
258+
debug("readBytesToSkip", readBytesToSkip);
256259

257260
let resp = await customFetch(fetchInfo.url, {
258261
headers: {
@@ -289,7 +292,7 @@ export class XetBlob extends Blob {
289292
const result = await reader.read();
290293
done = result.done;
291294

292-
console.log("read", result.value?.length, "bytes", "total read", totalBytesRead, "toSkip", readBytesToSkip);
295+
debug("read", result.value?.length, "bytes", "total read", totalBytesRead, "toSkip", readBytesToSkip);
293296

294297
if (!result.value) {
295298
continue;
@@ -315,7 +318,7 @@ export class XetBlob extends Blob {
315318
uncompressed_length: header.getUint8(5) | (header.getUint8(6) << 8) | (header.getUint8(7) << 16),
316319
};
317320

318-
console.log("chunk header", chunkHeader, "to skip", readBytesToSkip);
321+
debug("chunk header", chunkHeader, "to skip", readBytesToSkip);
319322

320323
if (chunkHeader.version !== 0) {
321324
throw new Error(`Unsupported chunk version ${chunkHeader.version}`);
@@ -377,18 +380,10 @@ export class XetBlob extends Blob {
377380
}
378381

379382
if (uncompressed.length) {
380-
console.log(
381-
"yield",
382-
uncompressed.length,
383-
"bytes",
384-
result.value.length,
385-
"total read",
386-
totalBytesRead,
387-
stored
388-
);
383+
debug("yield", uncompressed.length, "bytes", result.value.length, "total read", totalBytesRead, stored);
389384
totalBytesRead += uncompressed.length;
390385
yield stored ? uncompressed.slice() : uncompressed;
391-
console.log(
386+
debug(
392387
"yielded",
393388
uncompressed.length,
394389
"bytes",
@@ -405,7 +400,7 @@ export class XetBlob extends Blob {
405400
}
406401
}
407402

408-
console.log("done", done, "total read", totalBytesRead);
403+
debug("done", done, "total read", totalBytesRead);
409404

410405
// Release the reader
411406
await reader.cancel();

0 commit comments

Comments
 (0)