Skip to content

Fix Deno filesystem error context - #7086

Merged
tim-smart merged 4 commits into
mainfrom
agent/codex-engineer/1b6e1f66
Aug 6, 2026
Merged

Fix Deno filesystem error context#7086
tim-smart merged 4 commits into
mainfrom
agent/codex-engineer/1b6e1f66

Conversation

@tim-smart

Copy link
Copy Markdown
Contributor

Summary

  • preserve writeFile method and path context when high-level Deno writes delegate to FileImpl
  • normalize name-only Deno.errors.AlreadyExists failures produced by @std/fs copy
  • add focused filesystem and internal error-mapping regressions
  • add a patch changeset for @effect/platform-deno

Root cause

Non-native writeFile flag handling reused FileImpl.writeAll, which labeled failures as writeAll without the original path. Separately, the copy helper constructs Deno.errors.AlreadyExists without an errno-style code, while the adapter only recognized EEXIST.

Validation

  • deno task test --run --project @effect/platform-deno (205 passed, 11 skipped)
  • pnpm --filter @effect/platform-deno check
  • focused dprint and oxlint checks on the changed files

Closes EFF-527

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6dfba01

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

@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.

✅ No new issues found.

Reviewed changes
This PR fixes error-context loss in the Deno FileSystem implementation and normalizes an error mapping for @std/fs copy.

  • .changeset/deno-write-copy-errors.md — adds a patch changeset for @effect/platform-deno.
  • packages/platform-deno/src/DenoFileSystem.ts — threads method and pathOrDescriptor through FileImpl.writeChunk / writeAllChunk / writeAll so that high-level writeFile calls report the original method and path even when they delegate to the file-handle writer.
  • packages/platform-deno/src/internal/error.ts — maps Deno.errors.AlreadyExists by name so that errors produced without an errno-style code are tagged correctly.
  • packages/platform-deno/test/DenoFileSystem.test.ts — adds regression tests for the writeFile error context and the copy AlreadyExists mapping.
  • packages/platform-deno/test/internal/error.test.ts — updates the AlreadyExists unit test to cover the name-only case.

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 | 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 6.92 KB 6.92 KB 0.00 KB (0.00%)
batching.ts 9.72 KB 9.72 KB 0.00 KB (0.00%)
brand.ts 6.40 KB 6.40 KB 0.00 KB (0.00%)
cache.ts 10.59 KB 10.59 KB 0.00 KB (0.00%)
config.ts 20.61 KB 20.61 KB 0.00 KB (0.00%)
differ.ts 20.21 KB 20.21 KB 0.00 KB (0.00%)
http-client.ts 21.50 KB 21.50 KB 0.00 KB (0.00%)
logger.ts 10.81 KB 10.81 KB 0.00 KB (0.00%)
metric.ts 8.86 KB 8.86 KB 0.00 KB (0.00%)
optic.ts 7.25 KB 7.25 KB 0.00 KB (0.00%)
pubsub.ts 14.86 KB 14.86 KB 0.00 KB (0.00%)
queue.ts 11.54 KB 11.54 KB 0.00 KB (0.00%)
schedule.ts 10.71 KB 10.71 KB 0.00 KB (0.00%)
schema-class.ts 19.14 KB 19.14 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.98 KB 28.98 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.28 KB 25.28 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.31 KB 13.31 KB 0.00 KB (0.00%)
schema-string.ts 10.85 KB 10.85 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.08 KB 15.08 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 21.93 KB 21.93 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.33 KB 24.33 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.17 KB 19.17 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.98 KB 18.98 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.86 KB 18.86 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.58 KB 22.58 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.48 KB 19.48 KB 0.00 KB (0.00%)
schema.ts 18.40 KB 18.40 KB 0.00 KB (0.00%)
stm.ts 12.59 KB 12.59 KB 0.00 KB (0.00%)
stream.ts 9.67 KB 9.67 KB 0.00 KB (0.00%)

}))
})

it.effect("reports delegated write errors as writeFile errors", () =>

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.

Add these tests to the shared suite instead.

return Effect.acquireUseRelease(
tryPromise("writeFile", path, () => Deno.open(path, openOptions(flag, options?.mode))),
(file) => new FileImpl(file, flag.startsWith("a")).writeAll(data),
(file) => new FileImpl(file, flag.startsWith("a")).writeAll(data, "writeFile", path),

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.

I think just map the system error reason instead of notifying FileImpl

@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.

✅ No new issues found.

Reviewed changes
This re-review covers the follow-up commit that addressed prior review feedback.

  • packages/platform-deno/src/DenoFileSystem.ts — replaced the FileImpl parameter-threading approach with a single Effect.mapError in writeFile, which rewrites the system error's method and pathOrDescriptor at the call site. This keeps FileImpl.writeAll/writeChunk/writeAllChunk unchanged and avoids leaking high-level metadata into the internal file writer.
  • packages/effect/test/FileSystem.test-utils.ts — added the writeFile error-context and copy AlreadyExists regression tests to the shared cross-platform suite.
  • packages/platform-deno/test/DenoFileSystem.test.ts — simplified to just invoke the shared testLayer, removing the now-duplicate Deno-specific tests.

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 | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

yield* fs.writeFileString(path, "data", { flag: "r" }).pipe(Effect.flip)
const error = yield* fs.writeFileString(path, "data", { flag: "r" }).pipe(Effect.flip)

assert(error.reason instanceof PlatformError.SystemError)

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.

Check the tag instead of using instanceof

(file) => new FileImpl(file, flag.startsWith("a")).writeAll(data),
(file) =>
new FileImpl(file, flag.startsWith("a")).writeAll(data).pipe(
Effect.mapError((error) =>

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.

Don't use instanceof

@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.

✅ No new issues found.

Reviewed changes
This re-review covers the follow-up commit that switched the new shared filesystem assertions from instanceof checks to _tag checks.

  • packages/effect/test/FileSystem.test-utils.ts — replaced PlatformError.SystemError/PlatformError imports and instanceof assertions with _tag !== "BadArgument" / _tag === "AlreadyExists" checks in the new writeFile error-context and copy AlreadyExists tests.
  • packages/platform-deno/src/DenoFileSystem.ts — aligned the mapError guard from error.reason instanceof PlatformError.SystemError to error.reason._tag !== "BadArgument", matching the shared test style.

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 | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@tim-smart
tim-smart enabled auto-merge (squash) August 6, 2026 10:05
@tim-smart
tim-smart merged commit c91f401 into main Aug 6, 2026
19 checks passed
@tim-smart
tim-smart deleted the agent/codex-engineer/1b6e1f66 branch August 6, 2026 10:07
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