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

Refactor socketioxide parsing #376

Merged
merged 87 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
65bb87d
feat(socketio): add custom parsers
Totodore Jul 6, 2024
4ffdb46
feat(socketio/parser): create parser mod to handle multiple parser
Totodore Jul 7, 2024
783ae8c
fix: tests
Totodore Jul 17, 2024
1789fa5
feat(engineio/str): impl serde for str
Totodore Jul 22, 2024
1508d2b
feat(socketio/packet): use for connect packet
Totodore Jul 22, 2024
1843298
test(socketio/parser): use encode/decode fn rather than opaque From i…
Totodore Jul 23, 2024
adbcdca
feat(socketio/parser): impl new msgpack parser
Totodore Jul 23, 2024
4450dfa
Merge branch 'main' into feat-custom-parser
Totodore Jul 23, 2024
824639f
chore(ci): add tests to clippy
Totodore Jul 23, 2024
c74a863
fix: clippy warnings
Totodore Jul 23, 2024
47fc926
fix(socketio/parser): remove empty msgpack parser
Totodore Jul 23, 2024
e7392ca
Merge branch 'feat-custom-parser' into feat-msgpack-parser
Totodore Jul 23, 2024
4b4b889
chore(test): switch to feature flag for test harness
Totodore Jul 25, 2024
24c3beb
Merge branch 'feat-custom-parser' into feat-msgpack-parser
Totodore Jul 25, 2024
7f6b82f
chore(test): switch to feature flag for test harness
Totodore Jul 25, 2024
4b9f095
refactor: rename parse/serialize to encode/decode
Totodore Jul 25, 2024
ed56c08
Merge branch 'feat-custom-parser' into feat-msgpack-parser
Totodore Jul 25, 2024
660a3ba
feat(socketio/parser): wip msgpack parser
Totodore Aug 10, 2024
f0afe7d
chore(socketio/bench): improve packet benchmarks
Totodore Aug 10, 2024
4032882
Merge branch 'feat-custom-parser' into feat-msgpack-parser
Totodore Aug 10, 2024
9a57a70
--amend
Totodore Aug 14, 2024
2699258
--amend
Totodore Aug 14, 2024
a7394e1
Merge branch 'main' into feat-custom-parser
Totodore Aug 15, 2024
bde2577
Merge branch 'feat-custom-parser' into feat-msgpack-parser
Totodore Aug 15, 2024
d3e98b3
feat: msgpack parser
Totodore Aug 22, 2024
938abd0
chore(ci): add e2e testing
Totodore Aug 24, 2024
9bc15aa
fix(parser/msgpack): remove attachment field for packets
Totodore Aug 25, 2024
0bf52b5
fix(parser/msgpack): allow other keys in the payload
Totodore Aug 26, 2024
fe8d636
feat(parser/msgpack): improve encoding/decoding with std
Totodore Aug 26, 2024
feec1e6
fix(parser/common): unwrap data array for events if there is only one…
Totodore Aug 26, 2024
e798e4f
refactor: move the crates to a crates folder
Totodore Aug 26, 2024
c1b0814
feat(parser/common): WIP serde
Totodore Aug 28, 2024
aaa24a2
feat(parser/common): improve tests
Totodore Aug 29, 2024
7fd56d6
feat(parser/common): working deserializer
Totodore Sep 1, 2024
8c2a8da
feat(parser/common): fix all parsers
Totodore Sep 1, 2024
7827b0a
fix(parser/common): incorrect output for `ser::get_size_hint`
Totodore Sep 2, 2024
b739bf5
refactor(parser/common): move `FirstElement` and `is_tuple` to core
Totodore Sep 2, 2024
4da61b7
feat(parser/msgpack): add msgpack parsing
Totodore Sep 2, 2024
cce02af
feat(parser/msgpack): working msgpack serde
Totodore Sep 4, 2024
e45a200
feat(core): major refactoring for value type
Totodore Sep 4, 2024
5240506
refactor(socketio): refactoring for new dynamic parser
Totodore Sep 6, 2024
2fb4e35
feat(parsers): add event handling + connect with default parser impl
Totodore Sep 22, 2024
e237e45
fix(socketio/client): early return for NeedsMoreBinaryData
Totodore Sep 22, 2024
e5388c0
feat(parser/common): handle binary payload for any values
Totodore Sep 23, 2024
b3d0138
Merge remote-tracking branch 'origin/main' into crate-refactor-parsers
Totodore Sep 23, 2024
3bc063d
feat(socket.io/parser): improve tracing logs for bin
Totodore Sep 28, 2024
bc01b16
feat(parser/msgpack): fix socket.io js undefined encoding
Totodore Sep 28, 2024
469c85e
chore(testing): unwrap errors rather than discarding
Totodore Sep 29, 2024
214a1ad
feat(socketio): improve logging
Totodore Sep 29, 2024
98a7863
fix(parser/msgpack): fix `read_event` impl
Totodore Sep 29, 2024
6a98242
fix(parser/common): skip_first_element for AnyVisitor
Totodore Sep 29, 2024
95c5782
Merge branch 'main' into crate-refactor-parsers
Totodore Sep 29, 2024
9d7a778
chore(doc): fix doctesting
Totodore Sep 29, 2024
986c365
chore(clippy): fix clippy lints
Totodore Sep 29, 2024
bb4b0f7
fix(tracing): add feature flag for tracing flag
Totodore Sep 29, 2024
85fb403
chore(ci): fix ci pipeline
Totodore Sep 30, 2024
f766725
WIP: fix examples
Totodore Sep 30, 2024
5ad3579
feat(socketio): use `Deserialize` rather than `DeserializeOwned` bound
Totodore Sep 30, 2024
4ac969b
fix: lifetime issue
Totodore Sep 30, 2024
cbe254b
fix(examples): fix examples to work with new emit system
Totodore Oct 1, 2024
d92105b
chore(ci): fix ci/cd e2e testing
Totodore Oct 1, 2024
ebd1da5
chore(clippy): fix clippy lints
Totodore Oct 1, 2024
2e2c1f2
feat: add benchmarks
Totodore Oct 1, 2024
bddc7ef
example: add msgpack for examples
Totodore Oct 1, 2024
2f5c727
feat(socketio): improve error scope
Totodore Oct 1, 2024
ccba0bb
feat(socketio/parser): add feature flag for msgpack
Totodore Oct 1, 2024
f5bfdc6
chore(test): add more unit tests
Totodore Oct 2, 2024
8805918
doc: add doc for parsers
Totodore Oct 2, 2024
45f5b5c
fix: compilerversion for `on_unimplemented` msg
Totodore Oct 2, 2024
f302b95
chore(ci): add other crates to release pipeline
Totodore Oct 2, 2024
94bf75f
chore(clippy): remove deprecated clippy lint
Totodore Oct 2, 2024
6ad5dc5
feat(socketio/packet): use a `VecDeque` for binaries.
Totodore Oct 2, 2024
d540a92
fix: remove useless bin param for message handler
Totodore Oct 2, 2024
e996c67
feat: pre serialize the packet when broadcasting.
Totodore Oct 2, 2024
a449200
feat: add fuzzing for parsers
Totodore Oct 2, 2024
810c17e
chore(ci): add fuzzing
Totodore Oct 3, 2024
71d679f
doc(socketio): improve doc
Totodore Oct 4, 2024
8580914
fix(clippy): clippy doc lints
Totodore Oct 5, 2024
70856e8
feat(socketio): switch to AsStr to match emit
Totodore Oct 5, 2024
3fc6b47
fix(clippy): clippy doc lints
Totodore Oct 5, 2024
66179d1
fix: ci pipeline
Totodore Oct 5, 2024
8c208aa
remove serde_json error
Totodore Oct 5, 2024
0188b49
rename serde_json error
Totodore Oct 5, 2024
a94a32f
doc(socketio): fix parser json specific doc
Totodore Oct 16, 2024
2b42e78
doc: apply clippy lints
Totodore Oct 16, 2024
e3a26c9
fix(ci): add clippy tools
Totodore Oct 16, 2024
c3fbaf9
doc(socketio): add block on emitting binary data
Totodore Oct 18, 2024
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: 0 additions & 2 deletions .github/workflows/bencher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
BENCHER_CMD: cargo bench --all-features
BENCHER_PROJECT: socketioxide
RUSTFLAGS: --cfg=socketioxide_test

benchmark_pr:
if: github.event_name == 'workflow_dispatch' && github.event.pull_request.head.repo.full_name == github.repository
Expand Down Expand Up @@ -62,4 +61,3 @@ jobs:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
BENCHER_CMD: cargo bench --all-features
BENCHER_PROJECT: socketioxide
RUSTFLAGS: --cfg=socketioxide_test
73 changes: 73 additions & 0 deletions .github/workflows/fuzzing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: fuzzing

on:
workflow_dispatch:

permissions:
contents: read

jobs:
fuzzing_decode_value:
name: Fuzzing decode value
strategy:
fail-fast: false
matrix:
crate: [parser-common, parser-msgpack]
runs-on: ubuntu-latest
env:
TEST_DATA_VERSION: 0.0.2
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-fuzzing
- run: cargo install cargo-fuzz
- name: download corpus data
run: |
cd crates/${{ matrix.crate }}
wget https://github.com/Totodore/socketioxide-fuzzing-corpus/archive/refs/tags/v$TEST_DATA_VERSION.zip
unzip v$TEST_DATA_VERSION.zip
rm v$TEST_DATA_VERSION.zip
- name: cargo fuzz run decode_value
run: |
cd crates/${{ matrix.crate }}
cargo fuzz run decode_value -- -timeout=5 -max_len=2048 -runs=2000000 -only_ascii=1 \
socketioxide-fuzzing-corpus-$TEST_DATA_VERSION/corpus-${{ matrix.crate }}
fuzzing_decode_packet:
name: Fuzzing decode packet
strategy:
fail-fast: false
matrix:
crate: [parser-common, parser-msgpack]
target: [decode_packet_bin, decode_packet_str]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-fuzzing
- run: cargo install cargo-fuzz
- name: cargo fuzz run decode_packet
run: |
cd crates/${{ matrix.crate }}
cargo fuzz run ${{ matrix.target }} -- -timeout=5 -max_len=2048 -runs=2000000 -only_ascii=1
19 changes: 7 additions & 12 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
toolchain: stable
components: rustfmt
- run: cargo fmt --all -- --check
env:
RUSTFLAGS: --cfg=socketioxide_test

test:
runs-on: ubuntu-latest
Expand All @@ -39,8 +37,6 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: cargo test --tests --all-features --workspace
env:
RUSTFLAGS: --cfg=socketioxide_test
udeps:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -90,8 +86,6 @@ jobs:

- name: check crates
run: cargo check -p socketioxide -p engineioxide --all-features
env:
RUSTFLAGS: --cfg=socketioxide_test

feature_set:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -179,16 +173,15 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-clippy

- name: Install required cargo
- name: Install required cargo
run: cargo install clippy-sarif sarif-fmt || true

- name: Run rust-clippy
run: cargo clippy
--all-features
--tests
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
continue-on-error: true
env:
RUSTFLAGS: --cfg=socketioxide_test

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
Expand Down Expand Up @@ -242,7 +235,7 @@ jobs:
needs: [test]
strategy:
matrix:
socketio-version: [v4, v5]
socketio-version: [v4, v5, v5-msgpack]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
Expand All @@ -267,9 +260,11 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-release
- name: Install deps & run tests
run: |
PARSER=$(echo ${{ matrix.socketio-version }} | cut -d'-' -f2 -s)
VERSION=$(echo ${{ matrix.socketio-version }} | cut -d'-' -f1)
cd socket.io-protocol/test-suite && npm install && cd ../..
cargo build -p socketioxide-e2e --bin socketioxide-e2e --features ${{ matrix.socketio-version }} --release
cargo run -p socketioxide-e2e --bin socketioxide-e2e --features ${{ matrix.socketio-version }} --release > server.txt & npm --prefix socket.io-protocol/test-suite test > client.txt
cargo build -p socketioxide-e2e --bin socketioxide-e2e --features $VERSION,$PARSER --release
cargo run -p socketioxide-e2e --bin socketioxide-e2e --features $VERSION,$PARSER --release > server.txt & npm --prefix socket.io-protocol/test-suite test > client.txt
- name: Server output
if: always()
run: cat server.txt
Expand Down
30 changes: 18 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ jobs:
- name: Get releasing version
working-directory: .
run: |
NEXT_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml) >> $GITHUB_ENV
echo NEXT_VERSION=$NEXT_VERSION >> $GITHUB_ENV
echo $NEXT_VERSION
NEXT_VERSION=$(sed -nE 's/^\s*version = "(.*?)"/\1/p' Cargo.toml) >> $GITHUB_ENV
echo NEXT_VERSION=$NEXT_VERSION >> $GITHUB_ENV
echo $NEXT_VERSION

- name: Check published version
run: |
PREV_VERSION=$(cargo search socketioxide --limit 1 | sed -nE 's/^[^"]*"//; s/".*//1p' -)
echo PREV_VERSION=$PREV_VERSION >> $GITHUB_ENV
echo $PREV_VERSION
PREV_VERSION=$(cargo search socketioxide --limit 1 | sed -nE 's/^[^"]*"//; s/".*//1p' -)
echo PREV_VERSION=$PREV_VERSION >> $GITHUB_ENV
echo $PREV_VERSION

- name: Cancel run
if: env.NEXT_VERSION == env.PREV_VERSION
Expand All @@ -44,17 +44,23 @@ jobs:

publish:
runs-on: ubuntu-latest
needs:
needs:
- git-tag
strategy:
fail-fast: false
max-parallel: 1
matrix:
package:
- crate: engineioxide
path: engineioxide
- crate: socketioxide
path: socketioxide
- crate: engineioxide
path: crates/engineioxide
- crate: socketioxide_core
path: crates/socketioxide_core
- crate: socketioxide_parser_common
path: crates/parser_common
- crate: socketioxide_parser_msgpack
path: crates/parser_msgpack
- crate: socketioxide
path: crates/socketioxide
steps:
- uses: dtolnay/rust-toolchain@stable
with:
Expand Down Expand Up @@ -89,4 +95,4 @@ jobs:
run: |
echo "Cargo Publishing..."
cargo publish --no-verify
echo "New version of $NEXT_VERSION has been published"
echo "New version of $NEXT_VERSION has been published"
9 changes: 2 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ today! As a contributor, here are the guidelines we would like you to follow:

## <a name="question"></a> Got a Question or Problem?

Please open a discussion on the [Q&A discussions](https://github.com/totodore/socketioxide/discussions) page.
Please open a discussion on the [Q&A discussions](https://github.com/totodore/socketioxide/discussions) page.
We want to keep GitHub Issues for bugs and feature requests. If you open an issue it will be moved to Discussions.

## <a name="issue"></a> Found a Bug?
Expand Down Expand Up @@ -139,11 +139,6 @@ You will need [rustc and cargo](www.rust-lang.org/tools/install).
```shell
git clone https://github.com/totodore/socketioxide
```
2. To test socketioxide don't forget to enable the flag `socketioxide_test` through the `RUSTFLAGS` environment variable:

```shell
export RUSTFLAGS="--cfg socketioxide_test"
```
2. Depending on what you want to change, clone the [socketio/engine.io-protocol](https://github.com/socketio/engine.io-protocol) repo or the [socketio/socket.io-protocol](https://github.com/socketio/socket.io-protocol) repo or both
```shell
git clone https://github.com/socketio/engine.io-protocol
Expand Down Expand Up @@ -261,4 +256,4 @@ The subject contains succinct description of the change:
### Body

Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.
The body should include the motivation for the change and contrast this with previous behavior.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ categories = [
license = "MIT"

[workspace]
members = ["engineioxide", "socketioxide", "e2e/*"]
default-members = ["engineioxide", "socketioxide"]
members = ["crates/*", "e2e/*", "crates/*/fuzz"]
default-members = ["crates/*"]
resolver = "2"

[workspace.dependencies]
Expand Down Expand Up @@ -45,5 +45,6 @@ matchit = "0.8.2"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
criterion = { version = "0.5.1", features = [
"rayon",
"html_reports",
], default-features = false }
axum = "0.7.2"
1 change: 1 addition & 0 deletions engineioxide/Cargo.toml → crates/engineioxide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ hyper-util = { workspace = true, features = ["tokio", "client-legacy"] }
[features]
v3 = ["memchr", "unicode-segmentation", "itoa"]
tracing = ["dep:tracing"]
__test_harness = []

[[bench]]
name = "packet_encode"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use crate::sid::Sid;

#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("error serializing json packet: {0:?}")]
Serialize(#[from] serde_json::Error),
#[error("error decoding binary packet from polling request: {0:?}")]
Base64(#[from] base64::DecodeError),
#[error("error decoding packet: {0:?}")]
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions engineioxide/src/lib.rs → crates/engineioxide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
clippy::needless_borrow,
clippy::match_wildcard_for_single_variants,
clippy::if_let_mutex,
clippy::mismatched_target_os,
clippy::await_holding_lock,
clippy::match_on_vec_items,
clippy::imprecise_flops,
Expand All @@ -36,7 +35,8 @@ pub use crate::str::Str;
pub use service::{ProtocolVersion, TransportType};
pub use socket::{DisconnectReason, Socket};

#[cfg(any(test, socketioxide_test))]
#[doc(hidden)]
#[cfg(feature = "__test_harness")]
pub use packet::*;

pub mod config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl TryInto<String> for Packet {
match self {
Packet::Open(open) => {
buffer.push('0');
buffer.push_str(&serde_json::to_string(&open)?);
buffer.push_str(&serde_json::to_string(&open).unwrap());
}
Packet::Close => buffer.push('1'),
Packet::Ping => buffer.push('2'),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 25 additions & 12 deletions engineioxide/src/socket.rs → crates/engineioxide/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
//! let svc = EngineIoService::new(Arc::new(MyHandler::default()));
//! ```
use std::{
collections::VecDeque,
sync::{
atomic::{AtomicU8, Ordering},
Arc,
Expand Down Expand Up @@ -108,10 +109,8 @@ impl From<&Error> for Option<DisconnectReason> {
match err {
WsTransport(tungstenite::Error::ConnectionClosed) => None,
WsTransport(_) | Io(_) => Some(DisconnectReason::TransportError),
BadPacket(_) | Serialize(_) | Base64(_) | StrUtf8(_) | PayloadTooLarge
| InvalidPacketLength | InvalidPacketType(_) => {
Some(DisconnectReason::PacketParsingError)
}
BadPacket(_) | Base64(_) | StrUtf8(_) | PayloadTooLarge | InvalidPacketLength
| InvalidPacketType(_) => Some(DisconnectReason::PacketParsingError),
HeartbeatTimeout => Some(DisconnectReason::HeartbeatTimeout),
_ => None,
}
Expand All @@ -126,8 +125,8 @@ pub struct Permit<'a> {
impl Permit<'_> {
/// Consume the permit and emit a message to the client.
#[inline]
pub fn emit(self, msg: String) {
self.inner.send(smallvec![Packet::Message(msg.into())]);
pub fn emit(self, msg: Str) {
self.inner.send(smallvec![Packet::Message(msg)]);
}
/// Consume the permit and emit a binary message to the client.
#[inline]
Expand All @@ -138,9 +137,21 @@ impl Permit<'_> {
/// Consume the permit and emit a message with multiple binary data to the client.
///
/// It can be used to ensure atomicity when sending a string packet with adjacent binary packets.
pub fn emit_many(self, msg: String, data: Vec<Bytes>) {
pub fn emit_many(self, msg: Str, data: VecDeque<Bytes>) {
let mut packets = SmallVec::with_capacity(data.len() + 1);
packets.push(Packet::Message(msg));
for d in data {
packets.push(Packet::Binary(d));
}
self.inner.send(packets);
}

/// Consume the permit and emit a message with multiple binary data to the client.
///
/// It can be used to ensure atomicity when sending a string packet with adjacent binary packets.
pub fn emit_many_binary(self, bin: Bytes, data: Vec<Bytes>) {
let mut packets = SmallVec::with_capacity(data.len() + 1);
packets.push(Packet::Message(msg.into()));
packets.push(Packet::Binary(bin));
for d in data {
packets.push(Packet::Binary(d));
}
Expand All @@ -155,7 +166,7 @@ pub(crate) type PacketBuf = SmallVec<[Packet; 10]>;
///
/// It handles :
/// * the packet communication between with the `Engine`
/// and the user defined [`Handler`](crate::handler::EngineIoHandler).
/// and the user defined [`Handler`](crate::handler::EngineIoHandler).
/// * the user defined [`Data`](crate::handler::EngineIoHandler::Data) bound to the socket.
/// * the heartbeat job that verify that the connection is still up by sending packets periodically.
pub struct Socket<D>
Expand Down Expand Up @@ -185,7 +196,7 @@ where
/// * From the [encoder](crate::service::encoder) if the transport is polling
/// * From the fn [`on_ws_req_init`](crate::engine::EngineIo) if the transport is websocket
/// * Automatically via the [`close_session fn`](crate::engine::EngineIo::close_session) as a fallback.
/// Because with polling transport, if the client is not currently polling then the encoder will never be able to close the channel
/// Because with polling transport, if the client is not currently polling then the encoder will never be able to close the channel
///
/// The channel is made of a [`SmallVec`] of [`Packet`]s so that adjacent packets can be sent atomically.
pub(crate) internal_rx: Mutex<PeekableReceiver<PacketBuf>>,
Expand Down Expand Up @@ -469,7 +480,8 @@ impl<D: Default + Send + Sync + 'static> std::fmt::Debug for Socket<D> {
}
}

#[cfg(socketioxide_test)]
#[doc(hidden)]
#[cfg(feature = "__test_harness")]
impl<D> Drop for Socket<D>
where
D: Default + Send + Sync + 'static,
Expand All @@ -480,7 +492,8 @@ where
}
}

#[cfg(any(socketioxide_test, test))]
#[doc(hidden)]
#[cfg(feature = "__test_harness")]
impl<D> Socket<D>
where
D: Default + Send + Sync + 'static,
Expand Down
Loading