Add an Effect-native TDS driver for sql-mssql - #8129
Conversation
🦋 Changeset detectedLatest commit: 73abe74 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
Benchmark resultsResults for Environment: Node 24.20.0, SQL Server 2022 CU26 (16.0.4265.3), Linux amd64 Docker container under emulation on an ARM Mac, with TLS enabled for both drivers.
Method
These are directional results, not production performance guarantees. The host was not isolated, unrelated activity was not controlled, and samples vary materially. The DONEPROC result is a narrow microbenchmark, not a claim about all codecs. Latency percentiles, memory/GC, remote servers and concurrent pool load still need measurement. |
Bundle-size comparisonMeasured the original tedious-based adapter (
The native version saves approximately 1 MB of minified JavaScript. It adds only Measurement method
Exact byte counts:
Compatibility caveat: the old dependency bundle includes automatic Azure credential-provider functionality. The native driver delegates token acquisition to the application, so this is not a completely feature-equivalent comparison; an application adding an Azure credential SDK would add its size separately. |
Bundle-size comparison with RolldownAlso measured the original tedious-based adapter (
Measurement method
Exact byte counts:
The same compatibility caveat applies: the old dependency bundle includes automatic Azure credential-provider functionality, whereas the native driver delegates token acquisition to the application. Applications adding an Azure credential SDK would add its size separately. |
|
One question remaining: should we include a effect native character encoding/decoding functions to remove the iconv-lite dependency? i see @effect/sql-mysql2 is also using this for character encoding/decoding, so including this generally could remove the dependency when there is a native mysql2 implementation |
Summary
Following the native PostgreSQL driver in #7426, replace
@effect/sql-mssql'stedious runtime dependency with a native TDS 7.4 implementation owned by Effect.
Tedious remains a devDependency only for reproducible comparisons.
This is a draft, not a claim of complete tedious compatibility.
Implemented:
NTLMv2 and Security Token FedAuth, named-instance SSRP discovery, routing and
bounded startup retries. Access tokens are acquired through an Effect for each
new pooled connection. LOGIN7 also advertises UTF-8 support.
stored procedures, output parameters and return values.
serialized requests, timeouts and ATTENTION acknowledgement before reuse.
MssqlTypes, preserving SQL bigint strings and numeric results.Validation
on
a8ce97f59: Node, Bun, Deno, static checks, types, build, docs and bundle.2022 CU26 in Docker, including existing persistence/cache/queue suites.
without any manually configured port. This fixes the initial CI connection-refused
failures; exhaustive framing tests run serially to avoid starving sibling tests.
the encrypted peer asserts handshake records remain TDS-wrapped through reconnects.
rollover at reduced scales, verified against SQL Server.
acknowledgements, malformed acknowledgement rejection and per-connection providers.
cancellation races and timeout recovery tests.
pnpm lint-fixand package TypeScript check pass.pnpm checkpasses with the exact candidate in an isolated checkout.The nested development worktree reports unrelated test narrowing errors, so
clean-baseline and candidate checks were repeated separately.
pnpm jsdocs --checkreports two errors in unchangedpackages/effect/src/Logger.ts(
@seeordering andconsolePrettyresolution), none in this package.Live test command:
EFFECT_INTEGRATION_TESTS=1 MSSQL_PORT=14339 pnpm test --run packages/sql/mssql/testThe test helper uses fresh scoped databases when reusing an external container.
Benchmarks
Checked-in harness, raw samples and reproduction instructions are under
packages/sql/mssql/benchmark. Same TLS server, session settings, row conversion,result equality checks and alternating pairs against tedious 20.0.0.
Local paired median throughput changes after the TLS fixes: parameterized SELECT
+12.2%, 100×3 rowset +19.6%, 100×20 rowset +10.2%, large Unicode result +7.2%,
large Unicode parameter +10.4%, transaction cycle +11.3%.
The reused tedious DONEPROC parser workload shows +87.2% in a narrow microbenchmark.
The Docker amd64-on-ARM host was not isolated and samples contain outliers;
these are directional results, not release-level performance guarantees.
Remaining before a compatibility-complete replacement
Security Token FedAuth is implemented, but applications supply the token provider.
concurrent pools and memory/GC measurements.
Streaming was not implemented by the previous adapter and remains unsupported.
Rows are buffered with a 16 MiB per-token safety limit. UDT/Variant values can
be decoded but cannot be encoded as parameters; TVP rows are synchronous arrays.
Native descriptors replace tedious descriptor objects. Compatibility notes are
in the package README and changeset.
Protocol references: MS-TDS LOGIN7
and complete authentication token state.