Skip to content

Commit c2cc1d8

Browse files
committed
Revert "remove logging altogether"
This reverts commit d559933.
1 parent d5d8150 commit c2cc1d8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/hub/src/utils/XetBlob.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ interface ChunkHeader {
8282
const CHUNK_HEADER_BYTES = 8;
8383

8484
// eslint-disable-next-line @typescript-eslint/no-unused-vars
85+
const debug = (...args: unknown[]) => {};
8586

8687
/**
8788
* XetBlob is a blob implementation that fetches data directly from the Xet storage
@@ -159,6 +160,7 @@ export class XetBlob extends Blob {
159160
this.#reconstructionInfoPromise = (async () => {
160161
const connParams = await getAccessToken(this.repoId, this.accessToken, this.fetch, this.hubUrl);
161162

163+
// debug(
162164
// `curl '${connParams.casUrl}/reconstruction/${this.hash}' -H 'Authorization: Bearer ${connParams.accessToken}'`
163165
// );
164166

@@ -226,6 +228,7 @@ export class XetBlob extends Blob {
226228
const termRanges = rangeList.getRanges(term.range.start, term.range.end);
227229

228230
if (termRanges.every((range) => range.data)) {
231+
debug("all data available for term", term.hash, readBytesToSkip);
229232
rangeLoop: for (const range of termRanges) {
230233
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
231234
for (let chunk of range.data!) {
@@ -241,7 +244,7 @@ export class XetBlob extends Blob {
241244
chunk = chunk.slice(0, maxBytes - totalBytesRead);
242245
}
243246
totalBytesRead += chunk.length;
244-
247+
debug("yield", chunk.length, "bytes", "total read", totalBytesRead);
245248
// The stream consumer can decide to transfer ownership of the chunk, so we need to return a clone
246249
// if there's more than one range for the same term
247250
yield range.refCount > 1 ? chunk.slice() : chunk;
@@ -266,6 +269,10 @@ export class XetBlob extends Blob {
266269
);
267270
}
268271

272+
debug("term", term);
273+
debug("fetchinfo", fetchInfo);
274+
debug("readBytesToSkip", readBytesToSkip);
275+
269276
let resp = await customFetch(fetchInfo.url, {
270277
headers: {
271278
Range: `bytes=${fetchInfo.url_range.start}-${fetchInfo.url_range.end}`,
@@ -303,6 +310,8 @@ export class XetBlob extends Blob {
303310

304311
done = result.done;
305312

313+
debug("read", result.value?.length, "bytes", "total read", totalBytesRead, "toSkip", readBytesToSkip);
314+
306315
if (!result.value) {
307316
continue;
308317
}
@@ -327,6 +336,8 @@ export class XetBlob extends Blob {
327336
uncompressed_length: header.getUint8(5) | (header.getUint8(6) << 8) | (header.getUint8(7) << 16),
328337
};
329338

339+
debug("chunk header", chunkHeader, "to skip", readBytesToSkip);
340+
330341
if (chunkHeader.version !== 0) {
331342
throw new Error(`Unsupported chunk version ${chunkHeader.version}`);
332343
}
@@ -387,8 +398,10 @@ export class XetBlob extends Blob {
387398
}
388399

389400
if (uncompressed.length) {
401+
debug("yield", uncompressed.length, "bytes", result.value.length, "total read", totalBytesRead, stored);
390402
totalBytesRead += uncompressed.length;
391403
yield stored ? uncompressed.slice() : uncompressed;
404+
debug("yielded", uncompressed.length, "bytes", result.value.length, "total read", totalBytesRead);
392405
}
393406
}
394407

@@ -397,6 +410,8 @@ export class XetBlob extends Blob {
397410
}
398411
}
399412

413+
debug("done", done, "total read", totalBytesRead);
414+
400415
// Release the reader
401416
await reader.cancel();
402417
}

0 commit comments

Comments
 (0)