Skip to content

Honor writeFile flags in Deno - #7080

Merged
tim-smart merged 2 commits into
mainfrom
agent/codex-engineer/aa88313c
Aug 6, 2026
Merged

Honor writeFile flags in Deno#7080
tim-smart merged 2 commits into
mainfrom
agent/codex-engineer/aa88313c

Conversation

@tim-smart

@tim-smart tim-smart commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • honor every FileSystem.writeFile open flag in the Deno adapter
  • preserve native AbortSignal cancellation for w, wx, a, and ax writes
  • use Deno.open for read and + modes that Deno.writeFile cannot faithfully represent
  • handle empty writes without raising WriteZero
  • add shared filesystem coverage for read-only, read/write, append, exclusive-create, and empty-write behavior
  • add a patch changeset for @effect/platform-deno

Root cause

Deno.writeFile exposes only append/create/createNew booleans, so it cannot represent every Node-style open flag. In particular, r was writable and r+ truncated the file. Routing every mode through Deno.open fixed those semantics but regressed empty writes and cancellation. The hybrid implementation keeps the native, cancellable path where its semantics are sufficient and uses the complete Deno.open mapping for the remaining flags.

Validation

  • deno task test --run packages/platform-deno/test/DenoFileSystem.test.ts (19 passed, 1 skipped)
  • pnpm test --run packages/platform-node-shared/test/NodeFileSystem.test.ts (23 passed)
  • pnpm lint-fix
  • pnpm check

Closes EFF-522

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 049202c

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-deno Patch
effect Patch
@effect/ai-anthropic Patch
@effect/ai-openai Patch
@effect/ai-openai-compat Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node Patch
@effect/platform-node-shared 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/vitest 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-slopcop effect-slopcop Bot added 4.0 bug Something isn't working labels Aug 6, 2026
@tim-smart
tim-smart enabled auto-merge (squash) August 6, 2026 01:42
pullfrog[bot]
pullfrog Bot previously requested changes Aug 6, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

This PR introduces a regression for empty-file writes and drops the AbortSignal propagation that the previous Deno.writeFile implementation supported. Both issues stem from routing writeFile through Deno.open + FileImpl.writeAll; see the inline comment for details.

Reviewed changes

  • Replaced Deno Deno.writeFile with Deno.open + FileImpl.writeAll in packages/platform-deno/src/DenoFileSystem.ts to honor all OpenFlag semantics.
  • Added shared regression tests for r+, r, a, and wx write modes in packages/effect/test/FileSystem.test-utils.ts.
  • Added a patch changeset for @effect/platform-deno.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix it ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@pullfrog

pullfrog Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Follow-up detail for the CHANGES_REQUESTED review above: the inline comment did not attach, so here are the technical specifics for the two regressions.

Both issues center on packages/platform-deno/src/DenoFileSystem.ts:445, where writeFile now calls new FileImpl(file, ...).writeAll(data).

  1. Empty writes now fail. FileImpl.writeAllChunk treats 0 bytes written as a WriteZero system error, so writeFile(path, new Uint8Array()) and writeFileString(path, "") now fail instead of creating/truncating the file to empty. A minimal fix is to guard FileImpl.writeAll against empty buffers:

    writeAll(buffer: Uint8Array) {
      return buffer.length === 0 ? Effect.void : this.writeAllChunk(buffer)
    }
  2. Cancellation support is dropped. The previous implementation passed the AbortSignal from tryPromise into Deno.writeFile. Deno.open and Deno.FsFile.write do not accept a signal, so a long-running write can no longer be aborted. One option is a hybrid implementation that uses Deno.writeFile with signal for flags it can represent correctly (w, wx, a, ax) and falls back to Deno.open only for flags that require read or non-truncating write (r, r+, w+, wx+, a+, ax+).

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | via Pullfrog | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@github-actions

github-actions Bot commented Aug 6, 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
basic.ts 7.13 KB 7.13 KB 0.00 KB (0.00%)
batching.ts 9.92 KB 9.92 KB 0.00 KB (0.00%)
brand.ts 6.40 KB 6.40 KB 0.00 KB (0.00%)
cache.ts 10.78 KB 10.78 KB 0.00 KB (0.00%)
config.ts 20.79 KB 20.79 KB 0.00 KB (0.00%)
differ.ts 20.37 KB 20.37 KB 0.00 KB (0.00%)
http-client.ts 21.59 KB 21.59 KB 0.00 KB (0.00%)
logger.ts 10.90 KB 10.90 KB 0.00 KB (0.00%)
metric.ts 9.05 KB 9.05 KB 0.00 KB (0.00%)
optic.ts 7.25 KB 7.25 KB 0.00 KB (0.00%)
pubsub.ts 15.05 KB 15.05 KB 0.00 KB (0.00%)
queue.ts 11.72 KB 11.72 KB 0.00 KB (0.00%)
schedule.ts 10.89 KB 10.89 KB 0.00 KB (0.00%)
schema-class.ts 19.33 KB 19.33 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 29.15 KB 29.15 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.47 KB 25.47 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.48 KB 13.48 KB 0.00 KB (0.00%)
schema-string.ts 11.01 KB 11.01 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.27 KB 15.27 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 22.11 KB 22.11 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.50 KB 24.50 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.34 KB 19.34 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 19.17 KB 19.17 KB 0.00 KB (0.00%)
schema-toFormatter.ts 19.03 KB 19.03 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.75 KB 22.75 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.66 KB 19.66 KB 0.00 KB (0.00%)
schema.ts 18.57 KB 18.57 KB 0.00 KB (0.00%)
stm.ts 12.69 KB 12.69 KB 0.00 KB (0.00%)
stream.ts 9.86 KB 9.86 KB 0.00 KB (0.00%)

@pullfrog

pullfrog Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Run failed. View the logs →

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Rerun failed job ➔View workflow run | via Pullfrog | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@tim-smart
tim-smart merged commit c2c966d into main Aug 6, 2026
18 of 19 checks passed
@tim-smart
tim-smart deleted the agent/codex-engineer/aa88313c branch August 6, 2026 02:18
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