Skip to content

Commit

Permalink
tmp: disable ThpAck
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonlesisz committed Aug 29, 2024
1 parent 0138949 commit 1a86c30
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
15 changes: 10 additions & 5 deletions packages/transport/src/thp/receive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,29 @@ export const receiveThpMessage = async ({
apiWrite,
signal,
}: Omit<ReceiveThpMessageProps, 'messages'>): Promise<any> => {
const recvStart = Date.now();
console.warn('receiveThpMessage start', protocolState);

const decoded = await receive(
() => readWithExpectedState(apiRead, protocolState, signal),
v2Protocol,
);

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

const isAckExpected = protocolThp.isAckExpected(protocolState?.expectedResponses || []);
if (isAckExpected) {
const ack = protocolThp.encodeAck(decoded.header);
console.warn('Writing Ack', ack);
const ackResult = await apiWrite(ack, signal);
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');
// }
Expand Down
15 changes: 11 additions & 4 deletions packages/transport/src/thp/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ 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);
Expand All @@ -43,9 +44,15 @@ export const sendThpMessage = async ({
return sendResult;
}

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

return readWithExpectedState(apiRead, protocolState, attemptSignal);
return sendResult;

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

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

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

0 comments on commit 1a86c30

Please sign in to comment.