Skip to content

Fix filesystem and HTTP file range precision loss - #8110

Merged
tim-smart merged 10 commits into
mainfrom
eff-1309-precision-regressions
Sep 7, 2026
Merged

tim-smart merged 10 commits into
mainfrom
eff-1309-precision-regressions

Conversation

@tim-smart

@tim-smart tim-smart commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Filesystem writes and stats could silently round 9007199254740993 to 9007199254740992. Writes now reject unsafe positions with PlatformError / BadArgument. Stats request bigint values and preserve size and blksize exactly.

Number-typed metadata (dev, ino, rdev, mode, nlink, uid, gid, and blocks) must be safe integers. An unsafe value fails the whole stat operation, including optional fields. The public File.Info documentation explains that large inode values can therefore prevent stat and HTTP file serving even for small files.

HttpPlatform file responses keep content lengths as bigint and write exact decimal headers, so whole files above the safe integer limit remain supported. EOF clamping and static-server range arithmetic retain exact sizes, including suffix, open-ended, and 416 totals. Invalid numeric inputs and unrepresentable runtime range bounds fail with BadArgument instead of defects or rounding.

HttpPlatform.make now supplies bigint contentLength to its platform callback. Node and Deno compare empty lengths as bigint; Deno derives bounded stream lengths from checked numeric start/end bounds. The portable platform retains numeric body-length metadata only when safe and always preserves the exact header. Bun also writes the exact length header.

Writes retain checked numeric positions because callback-based fs.write ignores bigint positions. Small-file probes confirmed this on Node 18.0.0, 20.0.0, 22.0.0, 24.0.0, 26.4.0, and 26.7.0, matching Node's documented non-number position behavior. Oversized regression cases use doubles.

Validation at 3abe687:

  • 131 targeted Node/core tests, 20 Bun tests, and 75 Deno tests pass; one existing Deno test is skipped.
  • nix develop -c pnpm lint-fix, nix develop -c pnpm check, and Deno type checking of DenoHttpPlatform.ts pass.
  • nix develop -c pnpm test-types FileSystem.tst.ts passes on both selected TypeScript targets (16 assertions).
  • nix develop -c pnpm jsdocs --check reports only two errors in unchanged Logger.ts: an out-of-order @see and an unresolved consolePretty link.

Review cleanup at f2fd26b: precision coverage is consolidated into the existing test files and reduced from 63 cases to 20. Shared range validation runs in core; Node and Bun retain adapter-specific end-bound and exact-header checks. The changeset uses the suggested single sentence. Implementation is unchanged.

Current validation: all 85 tests across the five affected suites pass (71 Node/core, 14 Bun), down from 128 (108 Node/core, 20 Bun). Both runs used shuffled execution with seed 1309. pnpm lint-fix, pnpm check, and git diff --check pass.

Separate backlog follow-up: EFF-1310 covers HttpBody.file / fileFromInfo content-length precision loss and invalid range inputs causing defects, including HttpClientRequest.bodyFile. Assigned to The Boys; this PR does not implement that follow-up.

Closes EFF-1309

@changeset-bot

changeset-bot Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f2fd26b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch

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

@effect-janitor effect-janitor Bot added bug Something isn't working 4.0 labels Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 33.88 KB 33.88 KB 0.00 KB (0.00%)
basic.ts 6.87 KB 6.87 KB 0.00 KB (0.00%)
batching.ts 10.14 KB 10.14 KB 0.00 KB (0.00%)
brand.ts 6.45 KB 6.45 KB 0.00 KB (0.00%)
cache.ts 10.76 KB 10.76 KB 0.00 KB (0.00%)
config.ts 21.50 KB 21.50 KB 0.00 KB (0.00%)
differ.ts 20.27 KB 20.27 KB 0.00 KB (0.00%)
http-client.ts 22.10 KB 22.10 KB 0.00 KB (0.00%)
http-router.ts 33.55 KB 33.55 KB 0.00 KB (0.00%)
logger.ts 10.87 KB 10.87 KB 0.00 KB (0.00%)
metric.ts 9.00 KB 9.00 KB 0.00 KB (0.00%)
optic.ts 6.70 KB 6.70 KB 0.00 KB (0.00%)
pubsub.ts 15.26 KB 15.26 KB 0.00 KB (0.00%)
queue.ts 11.84 KB 11.84 KB 0.00 KB (0.00%)
schedule.ts 10.95 KB 10.95 KB 0.00 KB (0.00%)
schema-binary.ts 39.47 KB 39.47 KB 0.00 KB (0.00%)
schema-class.ts 20.04 KB 20.04 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.40 KB 30.40 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 26.24 KB 26.24 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.63 KB 13.63 KB 0.00 KB (0.00%)
schema-string.ts 11.11 KB 11.11 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.44 KB 15.44 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 33.43 KB 33.43 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.47 KB 24.47 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.23 KB 19.23 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 19.38 KB 19.38 KB 0.00 KB (0.00%)
schema-toFormatter.ts 19.48 KB 19.48 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 23.57 KB 23.57 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.53 KB 19.53 KB 0.00 KB (0.00%)
schema.ts 19.25 KB 19.25 KB 0.00 KB (0.00%)
stm.ts 12.78 KB 12.78 KB 0.00 KB (0.00%)
stream.ts 9.81 KB 9.81 KB 0.00 KB (0.00%)

@@ -0,0 +1,85 @@
import { assert, describe, it } from "@effect/vitest"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't create one-off tests files for this

@tim-smart
tim-smart merged commit 4ab4e83 into main Sep 7, 2026
13 checks passed
@tim-smart
tim-smart deleted the eff-1309-precision-regressions branch September 7, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant