Skip to content

Commit 5ef3f93

Browse files
committed
in replay, do not compare shard timestamp
1 parent 13672d8 commit 5ef3f93

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

packages/hub/scripts/debug-xet.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function createDebugFetch(args: { debugDir: string; replay?: boolean }): {
5858
console.error(` Local size: ${localData.length}, Upload size: ${uploadData.length}`);
5959
throw new Error(`Xorb validation failed for ${xorbFilename}`);
6060
}
61-
console.log(`✅ Xorb validation passed: ${xorbFilename}`);
61+
console.log(`✅ Xorb validation passed: ${xorbFilename} - xorb file is the same as generated previously`);
6262
return new Response(null, { status: 200 });
6363
} else {
6464
// In normal mode, save the data
@@ -85,13 +85,36 @@ function createDebugFetch(args: { debugDir: string; replay?: boolean }): {
8585
if (args.replay) {
8686
// In replay mode, compare with existing local file
8787
const localData = await readFile(shardPath);
88-
if (localData.length !== uploadData.length || !localData.every((byte, i) => byte === uploadData[i])) {
88+
if (localData.length !== uploadData.length) {
8989
console.error(`❌ Shard data mismatch: ${shardFilename}`);
9090
console.error(` Local size: ${localData.length}, Upload size: ${uploadData.length}`);
9191
throw new Error(`Shard validation failed for ${shardFilename}`);
9292
}
93-
console.log(`✅ Shard validation passed: ${shardFilename}`);
94-
return new Response(null, { status: 200 });
93+
94+
// Compare all bytes except footer bytes 104-112 (9 bytes from positions 104-112 inclusive)
95+
const footerStart = Number(
96+
new DataView(localData.buffer).getBigUint64(localData.buffer.byteLength - 8, true)
97+
);
98+
// This is the shard timestamp
99+
const toIgnoreStart = footerStart + 104;
100+
const toIgnoreEnd = footerStart + 112;
101+
102+
const mismatch = localData.some((byte, i) => {
103+
if (i >= toIgnoreStart && i < toIgnoreEnd) {
104+
return false;
105+
}
106+
return byte !== uploadData[i];
107+
});
108+
109+
if (mismatch) {
110+
console.error(`❌ Shard data mismatch: ${shardFilename}`);
111+
console.error(` Local size: ${localData.length}, Upload size: ${uploadData.length}`);
112+
throw new Error(`Shard validation failed for ${shardFilename}`);
113+
}
114+
console.log(`✅ Shard validation passed: ${shardFilename} - shard file is the same as generated previously`);
115+
116+
// Do not mock the shard call
117+
//return new Response(null, { status: 200 });
95118
} else {
96119
// In normal mode, save the data
97120
await writeFile(shardPath, uploadData);
@@ -263,10 +286,6 @@ async function main() {
263286
fetch: debugFetchObj.fetch,
264287
repo,
265288
rev: "main",
266-
yieldCallback: (event: { event: "fileProgress"; path: string; progress: number }) => {
267-
const progress = (event.progress * 100).toFixed(1);
268-
console.log(`📈 Progress for ${event.path}: ${progress}%`);
269-
},
270289
};
271290

272291
console.log(`\n=== Starting debug upload for ${filename} ===`);

0 commit comments

Comments
 (0)