Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quic"
version = "1.3.9"
version = "1.3.10"
authors = ["Roger Qiu <[email protected]>"]
license-file = "LICENSE"
edition = "2021"
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matrixai/quic",
"version": "1.3.9",
"version": "1.3.10",
"author": "Matrix AI",
"contributors": [
{
Expand Down Expand Up @@ -48,11 +48,11 @@
"ip-num": "^1.5.0"
},
"optionalDependencies": {
"@matrixai/quic-darwin-arm64": "1.3.9",
"@matrixai/quic-darwin-universal": "1.3.9",
"@matrixai/quic-darwin-x64": "1.3.9",
"@matrixai/quic-linux-x64": "1.3.9",
"@matrixai/quic-win32-x64": "1.3.9"
"@matrixai/quic-darwin-arm64": "1.3.10",
"@matrixai/quic-darwin-universal": "1.3.10",
"@matrixai/quic-darwin-x64": "1.3.10",
"@matrixai/quic-linux-x64": "1.3.10",
"@matrixai/quic-win32-x64": "1.3.10"
},
"devDependencies": {
"@fast-check/jest": "^1.1.0",
Expand Down
65 changes: 41 additions & 24 deletions src/QUICConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,30 +1029,47 @@ class QUICConnection {
);
continue;
}

quicStream = QUICStream.createQUICStream({
initiated: 'peer',
streamId,
config: this.config,
connection: this,
codeToReason: this.codeToReason,
reasonToCode: this.reasonToCode,
logger: this.logger.getChild(`${QUICStream.name} ${streamId}`),
});
this.streamMap.set(quicStream.streamId, quicStream);
quicStream.addEventListener(
events.EventQUICStreamSend.name,
this.handleEventQUICStreamSend,
);
quicStream.addEventListener(
events.EventQUICStreamDestroyed.name,
this.handleEventQUICStreamDestroyed,
{ once: true },
);
quicStream.addEventListener(EventAll.name, this.handleEventQUICStream);
this.dispatchEvent(
new events.EventQUICConnectionStream({ detail: quicStream }),
);
try {
this.conn.streamSend(streamId, Buffer.alloc(0), false);
utils.never(
'We never expect the stream to be writable if it was created during the writable iterator',
);
} catch (e) {
// If we got `FinalSize` during the writable iterator then we cleaned up an errant stream
if (e.message === 'FinalSize') continue;
if (utils.isStreamStopped(e) !== false) {
// In this case it was a stream that was created but errored out. We want to create a new stream for this one case.
quicStream = QUICStream.createQUICStream({
initiated: 'peer',
streamId,
config: this.config,
connection: this,
codeToReason: this.codeToReason,
reasonToCode: this.reasonToCode,
logger: this.logger.getChild(`${QUICStream.name} ${streamId}`),
});
this.streamMap.set(quicStream.streamId, quicStream);
quicStream.addEventListener(
events.EventQUICStreamSend.name,
this.handleEventQUICStreamSend,
);
quicStream.addEventListener(
events.EventQUICStreamDestroyed.name,
this.handleEventQUICStreamDestroyed,
{ once: true },
);
quicStream.addEventListener(
EventAll.name,
this.handleEventQUICStream,
);
this.dispatchEvent(
new events.EventQUICConnectionStream({ detail: quicStream }),
);
quicStream.write();
continue;
}
utils.never(`Expected to throw "FinalSize", got ${e.message}`);
}
}
quicStream.write();
}
Expand Down
5 changes: 5 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ class ErrorQUIC<T> extends AbstractError<T> {
static description = 'QUIC error';
}

class ErrorQUICUndefinedBehaviour<T> extends AbstractError<T> {
static description = 'You should never see this error';
}

class ErrorQUICHostInvalid<T> extends AbstractError<T> {
static description = 'Host provided was not valid';
}
Expand Down Expand Up @@ -293,6 +297,7 @@ class ErrorQUICStreamLimit<T> extends ErrorQUICStream<T> {

export {
ErrorQUIC,
ErrorQUICUndefinedBehaviour,
ErrorQUICHostInvalid,
ErrorQUICPortInvalid,
ErrorQUICConfig,
Expand Down
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import * as errors from './errors';
const textEncoder = new TextEncoder();
const textDecoder = new TextDecoder('utf-8');

function never(message: string): never {
throw new errors.ErrorQUICUndefinedBehaviour(message);
}

/**
* Used to yield to the event loop to allow other micro tasks to process
*/
Expand Down Expand Up @@ -572,6 +576,7 @@ function setMaxListeners(
export {
textEncoder,
textDecoder,
never,
yieldMicro,
promisify,
promise,
Expand Down
2 changes: 1 addition & 1 deletion tests/QUICStream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as testsUtils from './utils';
import { generateTLSConfig, sleep } from './utils';

describe(QUICStream.name, () => {
const logger = new Logger(`${QUICStream.name} Test`, LogLevel.WARN, [
const logger = new Logger(`${QUICStream.name} Test`, LogLevel.INFO, [
new StreamHandler(
formatting.format`${formatting.level}:${formatting.keys}:${formatting.msg}`,
),
Expand Down
Loading