Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hono-base): prevent options object mutation #3975

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

yusukebe
Copy link
Member

@yusukebe yusukebe commented Mar 4, 2025

Fixes #3970
Based on #3971

As the comment, the following test does not pass.

const opts = { strict: false }
const a1 = new Hono(opts)
const a2 = new Hono(opts)

a2.get('/hello', (c) => c.text('hello'))

const res = await a2.request('/hello/')
expect(res.status).toBe(200)
expect(await res.text()).toBe('hello')

This means opts passed to Hono's options will be mutated. This PR will fix it.

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

Copy link

github-actions bot commented Mar 4, 2025

Bundle size check

main (8796371) #3975 (bf85622) +/-
Bundle Size (B) 18,958B 18,948B -10B
Bundle Size (KB) 18.51K 18.5K -0.01K

Compiler Diagnostics

main (8796371) #3975 (bf85622) +/-
Files 261 261 0
Lines 116,442 116,441 -1
Identifiers 114,436 114,434 -2
Symbols 303,841 303,842 1
Types 214,827 214,832 5
Instantiations 3,091,598 3,091,594 -4
Memory used 453,418K 453,736K 318K
I/O read 0.02s 0.03s 0.01s
I/O write 0s 0s 0s
Parse time 0.81s 0.67s -0.14s
Bind time 0.36s 0.28s -0.08s
Check time 5.69s 5.56s -0.13s
Emit time 0s 0s 0s
Total time 6.86s 6.51s -0.35s

Reported by octocov

@yusukebe
Copy link
Member Author

yusukebe commented Mar 4, 2025

Hi @usualoma !

Can you review this?

Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.29%. Comparing base (8796371) to head (db51c9e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3975      +/-   ##
==========================================
- Coverage   91.29%   91.29%   -0.01%     
==========================================
  Files         168      168              
  Lines       10772    10771       -1     
  Branches     3057     3069      +12     
==========================================
- Hits         9834     9833       -1     
  Misses        937      937              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@usualoma
Copy link
Member

usualoma commented Mar 4, 2025

@yusukebe Thanks for the fix. I think it looks good!

@yusukebe
Copy link
Member Author

yusukebe commented Mar 4, 2025

@usualoma Thanks!

Hi @ehsan2003

You have created the PR, but I will merge this PR, making you a co-author. I appreciate your contribution!

@yusukebe yusukebe merged commit 2eaaa5e into main Mar 4, 2025
16 checks passed
@yusukebe yusukebe deleted the fix/hono-base-prevent-options-mutation branch March 4, 2025 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

defaultAppOptions not applying for the second app instance
2 participants