fix: missing context (set) in mapResponse for ElysiaFile#1432
Conversation
WalkthroughUpdated Bun adapter’s mapResponse to pass the response “set” object into handleFile when handling ElysiaFile, aligning with a revised handleFile signature that now accepts (File, set). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant Server as Elysia (Bun adapter)
participant Mapper as mapResponse
participant FileUtil as handleFile
participant Bun as Bun Response
Client->>Server: HTTP Request
Server->>Mapper: mapResponse(response, set)
alt response is ElysiaFile
Mapper->>FileUtil: handleFile(File, set) <!-- pass-through of set -->
Note right of FileUtil: Apply headers/status (e.g., CORS) via set
FileUtil-->>Mapper: File-based Response
else other response types
Mapper-->>Server: Mapped Response
end
Mapper-->>Server: Final Response
Server-->>Bun: send Response
Bun-->>Client: HTTP Response (headers applied)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)src/adapter/bun/handler.ts (2)
🔇 Additional comments (1)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fix #1427
Context
In mapResponse, the ElysiaFile case was calling handleFile without passing the current context (set).
Because of that, the response had no access to the headers defined by middleware/plugins, making it impossible for the CORS plugin to apply its headers.
Fix
Pass the current set object into handleFile in the ElysiaFile case so that headers (including CORS) are applied correctly.
Test
I didn’t write tests because this fix is very small and only restores the expected behavior (passing the current context to handleFile)
Enregistrement.de.l.ecran.2025-09-23.a.19.03.52.mov
Summary by CodeRabbit
Bug Fixes
Refactor