Skip to content

Commit

Permalink
more logging changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Oct 25, 2024
1 parent c67fe75 commit d5cfe4c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
1 change: 1 addition & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ describe(
await vi.waitFor(() => expect(onExit).toHaveBeenCalledTimes(1));
expect(onExit).toHaveBeenCalledWith(null, 0);

console.log(buffer.byteLength)
const lines = buffer.toString().trim().split('\n');
expect(lines.length).toBe(n + 1);

Check failure on line 313 in tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Build and test on x86_64-unknown-linux-gnu

tests/index.test.ts > PTY > ordering is correct

AssertionError: expected 841 to be 1025 // Object.is equality - Expected + Received - 1025 + 841 ❯ tests/index.test.ts:313:30

Check failure on line 313 in tests/index.test.ts

View workflow job for this annotation

GitHub Actions / Build and test on x86_64-unknown-linux-gnu

tests/index.test.ts > PTY > ordering is correct

AssertionError: expected 841 to be 1025 // Object.is equality - Expected + Received - 1025 + 841 ❯ tests/index.test.ts:313:30
for (let i = 0; i < n + 1; i++) {
Expand Down
14 changes: 4 additions & 10 deletions wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Pty {
#fd: number;

#handledClose: boolean = false;
#handledEndOfData: boolean = false;
#fdClosed: boolean = false;

#socket: ReadStream;
#writable: Writable;
Expand All @@ -73,7 +73,6 @@ export class Pty {
markReadFinished = resolve;
});
const mockedExit = (error: NodeJS.ErrnoException | null, code: number) => {
console.log('mocked exit');
markExited({ error, code });
};

Expand All @@ -92,27 +91,23 @@ export class Pty {

// catch end events
const handleClose = async () => {
if (this.#handledEndOfData) {
if (this.#fdClosed) {
return;
}

this.#handledEndOfData = true;
this.#fdClosed = true;

// must wait for fd close and exit result before calling real exit
console.log('handle end');
await readFinished;
const result = await exitResult;
realExit(result.error, result.code);
console.log('done');
};

this.read.on('end', () => {
console.log('end');
markReadFinished();
});

this.read.on('close', () => {
console.log('close');
handleClose();
});

Expand All @@ -132,7 +127,6 @@ export class Pty {
// is nothing left to read and we can start tearing things down. If we hadn't received an
// error so far, we are considered to be in good standing.
this.read.off('error', handleError);
console.log('eio');
this.#socket.emit('end');
return;
}
Expand All @@ -154,7 +148,7 @@ export class Pty {
}

resize(size: Size) {
if (this.#handledClose || this.#handledEndOfData) {
if (this.#handledClose || this.#fdClosed) {
return;
}

Expand Down

0 comments on commit d5cfe4c

Please sign in to comment.