Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: merge staging to master #104

Merged
merged 3 commits into from
Jun 4, 2024
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
2 changes: 1 addition & 1 deletion 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.2.7"
version = "1.2.8"
authors = ["Roger Qiu <roger.qiu@polyhack.io>"]
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.2.7",
"version": "1.2.8",
"author": "Matrix AI",
"contributors": [
{
Expand Down Expand Up @@ -48,11 +48,11 @@
"ip-num": "^1.5.0"
},
"optionalDependencies": {
"@matrixai/quic-darwin-arm64": "1.2.7",
"@matrixai/quic-darwin-universal": "1.2.7",
"@matrixai/quic-darwin-x64": "1.2.7",
"@matrixai/quic-linux-x64": "1.2.7",
"@matrixai/quic-win32-x64": "1.2.7"
"@matrixai/quic-darwin-arm64": "1.2.8",
"@matrixai/quic-darwin-universal": "1.2.8",
"@matrixai/quic-darwin-x64": "1.2.8",
"@matrixai/quic-linux-x64": "1.2.8",
"@matrixai/quic-win32-x64": "1.2.8"
},
"devDependencies": {
"@fast-check/jest": "^1.1.0",
Expand Down
17 changes: 16 additions & 1 deletion src/QUICServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
StreamReasonToCode,
} from './types';
import type { Header } from './native/types';
import nodesEvents from 'events';
tegefaulkes marked this conversation as resolved.
Show resolved Hide resolved
import Logger from '@matrixai/logger';
import { AbstractEvent, EventAll } from '@matrixai/events';
import {
Expand Down Expand Up @@ -62,6 +63,8 @@ class QUICServer {
protected _closed: boolean = false;
protected _closedP: Promise<void>;
protected resolveClosedP: () => void;
// Used to abort any starting connections when the server stops
protected stopAbortController: AbortController | undefined;

/**
* Handles `EventQUICServerError`.
Expand Down Expand Up @@ -370,6 +373,10 @@ class QUICServer {
reuseAddr?: boolean;
ipv6Only?: boolean;
} = {}) {
this.stopAbortController = new AbortController();
// Since we have a one-to-many relationship with clients and connections,
// we want to up the warning limit on the stopAbortController
nodesEvents.setMaxListeners(100000, this.stopAbortController.signal);
let address: string;
if (!this.isSocketShared) {
address = utils.buildAddress(host, port);
Expand Down Expand Up @@ -444,6 +451,11 @@ class QUICServer {
// Stop answering new connections
this.socket.unsetServer();
const connectionsDestroyP: Array<Promise<void>> = [];
// If force then signal for any starting connections to abort
if (force) {
this.stopAbortController?.abort(new errors.ErrorQUICServerStopping());
}
this.stopAbortController = undefined;
for (const connection of this.socket.connectionMap.serverConnections.values()) {
connectionsDestroyP.push(
connection.stop({
Expand Down Expand Up @@ -628,7 +640,10 @@ class QUICServer {
data,
remoteInfo,
},
{ timer: this.minIdleTimeout },
{
timer: this.minIdleTimeout,
signal: this.stopAbortController?.signal,
},
);
} catch (e) {
connection.removeEventListener(
Expand Down
5 changes: 5 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class ErrorQUICServerInternal<T> extends ErrorQUICServer<T> {
static description = 'QUIC Server internal error';
}

class ErrorQUICServerStopping<T> extends ErrorQUICServer<T> {
static description = 'QUIC Server is stopping';
}

class ErrorQUICConnection<T> extends ErrorQUIC<T> {
static description = 'QUIC Connection error';
}
Expand Down Expand Up @@ -306,6 +310,7 @@ export {
ErrorQUICServerSocketNotRunning,
ErrorQUICServerNewConnection,
ErrorQUICServerInternal,
ErrorQUICServerStopping,
ErrorQUICConnection,
ErrorQUICConnectionStopping,
ErrorQUICConnectionNotRunning,
Expand Down