Skip to content

Commit 73f58cc

Browse files
committed
fix: gracefully closing quic stream in memtest
1 parent ec79868 commit 73f58cc

File tree

3 files changed

+8
-4058
lines changed

3 files changed

+8
-4058
lines changed

Cargo.lock

Lines changed: 0 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/memtest.mjs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ const main = async () => {
313313
formatting.format`${formatting.level}:${formatting.keys}:${formatting.msg}`,
314314
),
315315
]);
316-
const localhost = '127.0.0.1';
317316
const key = await generateKeyHMAC();
318317
let socketCleanMethods = socketCleanupFactory();
319318
const serverCrypto = {
@@ -342,13 +341,11 @@ const main = async () => {
342341
server.addEventListener(events.EventQUICServerConnection.name, (e) =>
343342
connectionEventProm.resolveP(e),
344343
);
345-
await server.start({
346-
host: localhost,
347-
});
344+
await server.start({ host: '127.0.0.1' });
348345
const client = await QUICClient.createQUICClient({
349-
host: localhost,
346+
host: '127.0.0.1',
350347
port: server.port,
351-
localHost: localhost,
348+
localHost: '127.0.0.1',
352349
crypto: {
353350
ops: clientCrypto,
354351
},
@@ -373,11 +370,13 @@ const main = async () => {
373370
console.error('loop');
374371
const stream = client.connection.newStream();
375372
const writer = stream.writable.getWriter();
376-
const reader = stream.readable.getReader();
377373
await writer.write(message);
378-
await reader.read();
379374
await writer.close();
380-
await reader.cancel();
375+
const reader = stream.readable.getReader();
376+
let finished = false;
377+
while (!finished) {
378+
finished = (await reader.read()).done;
379+
}
381380
}
382381
await Promise.all([activeServerStreams]);
383382

0 commit comments

Comments
 (0)