Skip to content

Fix published pre-response handler types - #6433

Merged
tim-smart merged 3 commits into
Effect-TS:mainfrom
coyaSONG:agent/fix-published-pre-response-handler-types
Jul 19, 2026
Merged

Fix published pre-response handler types#6433
tim-smart merged 3 commits into
Effect-TS:mainfrom
coyaSONG:agent/fix-published-pre-response-handler-types

Conversation

@coyaSONG

@coyaSONG coyaSONG commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Preserve appendPreResponseHandlerUnsafe in release declaration output. HttpEffect publicly re-exports this function, but its implementation declaration was tagged @internal. Release builds enable stripInternal, so the symbol disappeared from internal/preResponseHandler.d.ts while HttpEffect.d.ts still imported and re-exported it. Consumers using strict library checking then received TS2305.

This change removes the erroneous internal marker, extends the existing lint rule to flag public named re-exports of @internal symbols, adds regression coverage, and includes a patch changeset.

Validation:

  • pnpm lint-fix
  • pnpm --dir packages/tools/oxc test --run (51 tests)
  • pnpm vitest run packages/effect/test/unstable/http/HttpEffect.test.ts (17 tests)
  • pnpm check
  • release-style declaration emit with --stripInternal true (the internal file now declares appendPreResponseHandlerUnsafe instead of emitting export {})

Prepared with OpenAI Codex assistance; repository guidance, scope, diff, and validation results were checked before publication.

Related

Summary by CodeRabbit

  • Bug Fixes

    • Corrected type declarations for the HTTP pre-response handler API.
    • Improved handling of pre-response handlers for both successful and failed HTTP responses.
    • Enhanced detection of internal exports unintentionally re-exported from public modules.
  • Developer Experience

    • Added clearer diagnostics for invalid public re-exports of internal APIs.
  • Tests

    • Added coverage for detecting internal exports re-exported by public modules.

@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9fab402

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

This PR includes changesets to release 27 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node 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/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/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

@IMax153 IMax153 added the 4.0 label Jul 16, 2026
@IMax153
IMax153 requested a review from gcanti July 16, 2026 21:39
@gcanti gcanti assigned tim-smart and unassigned gcanti Jul 17, 2026
@gcanti
gcanti requested review from tim-smart and removed request for gcanti July 17, 2026 07:35
/** @internal */
export const requestPreResponseHandlers = new WeakMap<object, PreResponseHandler>()

/** @internal */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should not remove internal annotations from exports in the internal folder, we should instead annotate with the type the public re-export

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bfb7539d-71f3-4101-8332-6fb2d3ef2689

📥 Commits

Reviewing files that changed from the base of the PR and between 7909a17 and 9fab402.

📒 Files selected for processing (2)
  • packages/effect/src/unstable/http/HttpEffect.ts
  • packages/tools/oxc/test/no-unused-internal.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/tools/oxc/test/no-unused-internal.test.ts

📝 Walkthrough

Walkthrough

The PR updates HTTP pre-response handler exports to produce a usable declaration and extends no-unused-internal to resolve and diagnose public re-exports of internal exports, with a corresponding test and changeset.

Changes

HTTP declaration fix

Layer / File(s) Summary
HTTP handler declaration and usage
packages/effect/src/unstable/http/HttpEffect.ts, .changeset/fix-http-pre-response-handler-types.md
HTTP response paths use namespace-qualified pre-response handlers, while appendPreResponseHandlerUnsafe is exported as an explicitly typed constant alias; the changeset records the patch release.

Internal export analysis

Layer / File(s) Summary
Re-export resolution and usage scanning
packages/tools/oxc/src/oxlint/rules/no-unused-internal.ts
Workspace-aware logic resolves named re-exports and marks the underlying internal exports as used.
Public re-export diagnostics and validation
packages/tools/oxc/src/oxlint/rules/no-unused-internal.ts, packages/tools/oxc/test/no-unused-internal.test.ts
Public named exports are scanned for internal re-exports, diagnostics and rule metadata are updated, and the behavior is covered by a test.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested labels: bug

Suggested reviewers: tim-smart

Sequence Diagram(s)

sequenceDiagram
  participant PublicModule
  participant no_unused_internal
  participant workspacePackages
  participant Diagnostic
  PublicModule->>no_unused_internal: provide named export declaration
  no_unused_internal->>workspacePackages: resolve re-exported source
  workspacePackages-->>no_unused_internal: return internal export matches
  no_unused_internal->>Diagnostic: report internal public re-export
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main fix to published pre-response handler types.
Linked Issues check ✅ Passed The changes address the declaration mismatch by removing the public re-export dependency and align with the linked issue's no-runtime-change requirement.
Out of Scope Changes check ✅ Passed The lint rule, regression test, and changeset all support the declaration fix and related prevention work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the bug Something isn't working label Jul 19, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/tools/oxc/test/no-unused-internal.test.ts (1)

89-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover direct export … from re-exports.

This fixture only exercises the imported-binding path. Add export { internal } from "./Internal.ts" to cover the new moduleSpecifier resolution branch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tools/oxc/test/no-unused-internal.test.ts` around lines 89 - 104,
Extend the test case in “reports public re-exports of `@internal` exports” to use
a direct export-from declaration, `export { internal } from "./Internal.ts"`, so
the moduleSpecifier resolution branch is exercised while preserving the expected
diagnostic and clean Internal.ts result.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/tools/oxc/test/no-unused-internal.test.ts`:
- Around line 89-104: Extend the test case in “reports public re-exports of
`@internal` exports” to use a direct export-from declaration, `export { internal }
from "./Internal.ts"`, so the moduleSpecifier resolution branch is exercised
while preserving the expected diagnostic and clean Internal.ts result.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c50c0d24-7156-48eb-a81b-8a8f7d65707f

📥 Commits

Reviewing files that changed from the base of the PR and between 80ea8cb and 7909a17.

📒 Files selected for processing (4)
  • .changeset/fix-http-pre-response-handler-types.md
  • packages/effect/src/unstable/http/internal/preResponseHandler.ts
  • packages/tools/oxc/src/oxlint/rules/no-unused-internal.ts
  • packages/tools/oxc/test/no-unused-internal.test.ts
💤 Files with no reviewable changes (1)
  • packages/effect/src/unstable/http/internal/preResponseHandler.ts

@tim-smart
tim-smart force-pushed the agent/fix-published-pre-response-handler-types branch from df1fb03 to a54b841 Compare July 19, 2026 22:23
@tim-smart
tim-smart marked this pull request as ready for review July 19, 2026 22:25
@tim-smart
tim-smart enabled auto-merge (squash) July 19, 2026 22:25
@tim-smart
tim-smart merged commit 31d3fc4 into Effect-TS:main Jul 19, 2026
15 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.66 KB 6.66 KB 0.00 KB (0.00%)
batching.ts 9.26 KB 9.26 KB 0.00 KB (0.00%)
brand.ts 6.14 KB 6.14 KB 0.00 KB (0.00%)
cache.ts 9.90 KB 9.90 KB 0.00 KB (0.00%)
config.ts 18.88 KB 18.88 KB 0.00 KB (0.00%)
differ.ts 17.10 KB 17.10 KB 0.00 KB (0.00%)
http-client.ts 20.58 KB 20.58 KB 0.00 KB (0.00%)
logger.ts 10.25 KB 10.25 KB 0.00 KB (0.00%)
metric.ts 8.52 KB 8.52 KB 0.00 KB (0.00%)
optic.ts 7.35 KB 7.35 KB 0.00 KB (0.00%)
pubsub.ts 14.09 KB 14.09 KB 0.00 KB (0.00%)
queue.ts 11.09 KB 11.09 KB 0.00 KB (0.00%)
schedule.ts 10.29 KB 10.29 KB 0.00 KB (0.00%)
schema-class.ts 17.95 KB 17.95 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 4.06 KB 4.06 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.33 KB 27.33 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.62 KB 12.62 KB 0.00 KB (0.00%)
schema-string.ts 10.29 KB 10.29 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.26 KB 14.26 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 20.73 KB 20.73 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 21.31 KB 21.31 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 17.92 KB 17.92 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 17.81 KB 17.81 KB 0.00 KB (0.00%)
schema-toFormatter.ts 17.64 KB 17.64 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 20.21 KB 20.21 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 18.20 KB 18.20 KB 0.00 KB (0.00%)
schema.ts 17.23 KB 17.23 KB 0.00 KB (0.00%)
stm.ts 12.02 KB 12.02 KB 0.00 KB (0.00%)
stream.ts 9.29 KB 9.29 KB 0.00 KB (0.00%)

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.

effect@4.0.0-beta.98 publishes empty preResponseHandler.d.ts used by HttpEffect

5 participants