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
48 changes: 48 additions & 0 deletions package-lock.json

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

20 changes: 5 additions & 15 deletions src/QUICStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,11 @@ class QUICStream implements ReadableWritablePair<Uint8Array, Uint8Array> {
// This will setup the readable chunk buffer with the size set to the
// configured per-stream buffer size. Note that this doubles the memory
// usage of each stream due to maintaining both the Rust and JS buffers
if (this.type === 'uni') {
if (initiated === 'local') {
// We expect the readable stream to be closed
this.readableChunk = undefined;
} else if (initiated === 'peer') {
this.readableChunk = Buffer.allocUnsafe(config.initialMaxStreamDataUni);
}
} else if (this.type === 'bidi' && initiated === 'local') {
this.readableChunk = Buffer.allocUnsafe(
config.initialMaxStreamDataBidiLocal,
);
} else if (this.type === 'bidi' && initiated === 'peer') {
this.readableChunk = Buffer.allocUnsafe(
config.initialMaxStreamDataBidiRemote,
);
if (this.type === 'uni' && initiated === 'local') {
// We expect the readable stream to be closed
this.readableChunk = undefined;
} else {
this.readableChunk = Buffer.allocUnsafe(config.readableChunkSize);
}
if (this.type === 'uni' && initiated === 'local') {
// This is just a dummy stream that will be auto-closed during creation
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const clientDefault: QUICConfig = {
disableActiveMigration: true,
applicationProtos: ['quic'],
enableEarlyData: true,
readableChunkSize: 4 * 1024,
};

const serverDefault: QUICConfig = {
Expand All @@ -83,6 +84,7 @@ const serverDefault: QUICConfig = {
disableActiveMigration: true,
applicationProtos: ['quic'],
enableEarlyData: true,
readableChunkSize: 4 * 1024,
};

/**
Expand Down
8 changes: 7 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ type QUICConfig = {
logKeys?: string;

/**
* Enable "Generate Random extensions and Sustain Extensibilty".
* Enable "Generate Random extensions and Sustain Extensibility".
* This prevents protocol ossification by periodically introducing
* random no-op values in the optional fields in TLS.
* This defaults to true.
Expand Down Expand Up @@ -305,6 +305,12 @@ type QUICConfig = {
applicationProtos: string[];

enableEarlyData: boolean;

/**
* Defines the size of the Buffer used to read out data from the readable stream.
* This affects amount of memory reserved by the stream.
*/
readableChunkSize: number;
};

type QUICClientConfigInput = Partial<QUICConfig>;
Expand Down