Skip to content

Commit 44e16b0

Browse files
committed
Continue debugging journey for race condition
1 parent 5dc9f12 commit 44e16b0

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

code/bitjs/archive/unzip.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ export function connect(port) {
789789

790790
hostPort = port;
791791
port.onmessage = onmessage;
792+
// TODO: kthoom change for debugging.
792793
console.log(`debugFetch: Connected host to unzip implementation`);
793794
}
794795

code/bitjs/archive/webworker-wrapper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ onmessage = async (evt) => {
2222
if (evt.data.implSrc) {
2323
module = await import(evt.data.implSrc);
2424
module.connect(evt.ports[0]);
25+
// TODO: kthoom change for debugging.
2526
postMessage('connected');
2627
} else if (evt.data.disconnect) {
2728
module.disconnect();

code/epub/epub-book-binder.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ export class EPUBBookBinder extends BookBinder {
5050
constructor(filenameOrUri, ab, totalExpectedSize) {
5151
super(filenameOrUri, ab, totalExpectedSize);
5252

53+
if (Params['debugFetch'] === 'true') {
54+
console.log(`debugFetch: Constructing a EPUBBookBinder for ${filenameOrUri}`);
55+
}
56+
5357
/**
5458
* A map of all files in the archive, keyed by its full path in the archive with the value
5559
* being the raw ArrayBuffer.
@@ -76,9 +80,13 @@ export class EPUBBookBinder extends BookBinder {
7680
/** @override */
7781
beforeStart_() {
7882
let firstFile = true;
79-
this.unarchiver.addEventListener(UnarchiveEventType.EXTRACT, evt => {
83+
this.unarchiver.onExtract(evt => {
8084
/** @type {import('../bitjs/archive/decompress.js').UnarchivedFile} */
8185
const theFile = evt.unarchivedFile;
86+
if (Params['debugFetch'] === 'true' && this.fileMap_.has(theFile.filename)) {
87+
// TODO: How does it get multiple extract events for the same file?
88+
debugger;
89+
}
8290
this.fileMap_.set(theFile.filename, theFile.fileData);
8391
if (Params['debugFetch'] === 'true') {
8492
console.log(`debugFetch: Extracted file ${theFile.filename} of size ${theFile.fileData.byteLength}`);

0 commit comments

Comments
 (0)