Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "tmp: disable ThpAck"
Browse files Browse the repository at this point in the history
This reverts commit 16215cf5e348c532c690abb1f467c93db3cc934b.
szymonlesisz committed Sep 16, 2024
1 parent 7c23902 commit b2da7e9
Showing 2 changed files with 7 additions and 19 deletions.
11 changes: 3 additions & 8 deletions packages/transport/src/thp/receive.ts
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@ export const receiveThpMessage = async ({
apiWrite,
signal,
}: Omit<ReceiveThpMessageProps, 'messages'>): ReturnType<typeof receive> => {
const recvStart = Date.now();
console.warn('receiveThpMessage start', protocolState);

const decoded = await receive(
@@ -70,21 +69,17 @@ export const receiveThpMessage = async ({
return decoded;
}

console.warn('receiveThpMessage received', recvStart - Date.now());

const isAckExpected = protocolThp.isAckExpected(protocolState?.expectedResponses || []);
if (isAckExpected) {
const ack = protocolThp.encodeAck(decoded.payload.header);
console.warn('Writing Ack', ack, typeof apiWrite);
// const ackResult = await apiWrite(ack, signal);

// if (!ackResult.success) {
// // TODO: what to do here?
// }
if (!ackResult.success) {
// TODO: what to do here?
}
}

console.warn('receiveThpMessage end', recvStart - Date.now());

// if (isAckExpected) {
// protocolState?.updateSyncBit('recv');
// }
15 changes: 4 additions & 11 deletions packages/transport/src/thp/send.ts
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@ export const sendThpMessage = async ({

const attempt = async (): ReturnType<typeof apiRead> => {
try {
const sendStart = Date.now();
const result = await scheduleAction(
async attemptSignal => {
console.warn('---> sendThpMessage attempt start', tries);
@@ -44,15 +43,9 @@ export const sendThpMessage = async ({
return sendResult;
}

console.warn(
'...trying to read ack',
typeof readWithExpectedState,
typeof attemptSignal,
);
console.warn('...trying to read ack', tries);

return sendResult;

// return readWithExpectedState(apiRead, protocolState, attemptSignal);
return readWithExpectedState(apiRead, protocolState, attemptSignal);
},
{
signal,
@@ -68,9 +61,9 @@ export const sendThpMessage = async ({
},
);

console.warn('sendWithRetransmission result', tries, Date.now() - sendStart, result);
console.warn('sendWithRetransmission result', tries, result);

return result as any;
return result;
} catch (error) {
console.warn('sendWithRetransmission error', tries, error);
throw error; // TODO: return { success: false } and handle it in result below

0 comments on commit b2da7e9

Please sign in to comment.