Skip to content

Commit 48554c1

Browse files
committed
Improve accuracy of raw tunnel timestamps
1 parent 5f944b7 commit 48554c1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/server/mockttp-server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,22 +1209,24 @@ ${await this.suggestRule(request)}`
12091209

12101210
if (type === 'raw') {
12111211
socket.on('data', (data) => {
1212+
const eventTimestamp = now();
12121213
setImmediate(() => {
12131214
this.eventEmitter.emit('raw-passthrough-data', {
12141215
id: eventData.id,
12151216
direction: 'received',
12161217
content: data,
1217-
eventTimestamp: now()
1218+
eventTimestamp
12181219
} satisfies RawPassthroughDataEvent);
12191220
});
12201221
});
12211222
upstreamSocket.on('data', (data) => {
1223+
const eventTimestamp = now();
12221224
setImmediate(() => {
12231225
this.eventEmitter.emit('raw-passthrough-data', {
12241226
id: eventData.id,
12251227
direction: 'sent',
12261228
content: data,
1227-
eventTimestamp: now()
1229+
eventTimestamp
12281230
} satisfies RawPassthroughDataEvent);
12291231
});
12301232
});

0 commit comments

Comments
 (0)