hono icon indicating copy to clipboard operation
hono copied to clipboard

feat(context-storage): Add optional tryGetContext helper to context-storage middleware

Open AyushCoder9 opened this issue 1 month ago • 12 comments

introduce getContextIfAny, which returns the stored context or undefined without throwing make the existing getContext delegate to the softer helper so behavior stays unchanged when no context exists expand the context-storage tests to cover both success and missing-context scenarios for the new helper

AyushCoder9 avatar Nov 24 '25 18:11 AyushCoder9

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 91.49%. Comparing base (342ff3b) to head (15cde5d).

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #4539      +/-   ##
==========================================
- Coverage   91.52%   91.49%   -0.03%     
==========================================
  Files         172      172              
  Lines       11221    11233      +12     
  Branches     3255     3258       +3     
==========================================
+ Hits        10270    10278       +8     
- Misses        950      954       +4     
  Partials        1        1              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Nov 25 '25 10:11 codecov[bot]

This PR will resolve #4536.

yusukebe avatar Nov 26 '25 10:11 yusukebe

@AyushCoder9 Thank you for the PR!

Hi @elibarzilay! What do you think of this PR? I think good.

yusukebe avatar Nov 26 '25 10:11 yusukebe

@AyushCoder9 Thank you for the PR!

Hi @elibarzilay! What do you think of this PR? I think good.

LGTM either way -- I specifically avoided thinking too much about a good name, to leave it up to people who might know the codebase better :)

elibarzilay avatar Nov 29 '25 16:11 elibarzilay

@AyushCoder9 Thank you for the PR!

Hi @elibarzilay! What do you think of this PR? I think good.

LGTM either way -- I specifically avoided thinking too much about a good name, to leave it up to people who might know the codebase better :)

@elibarzilay are you merging this pr ? Tell me if I need to change something !!

AyushCoder9 avatar Nov 29 '25 17:11 AyushCoder9

I'm just the person who made the feature request, I'm not a regular contributor...

(Also, I'm guessing that it would be good to get a blessing from @marceloverdijk since he wrote the code.)

elibarzilay avatar Nov 29 '25 17:11 elibarzilay

I'm just the person who made the feature request, I'm not a regular contributor...

(Also, I'm guessing that it would be good to get a blessing from @marceloverdijk since he wrote the code.)

@marceloverdijk check if this pr is good enough

AyushCoder9 avatar Nov 30 '25 11:11 AyushCoder9

👍 I think it looks good (and a nice addition)

marceloverdijk avatar Dec 01 '25 14:12 marceloverdijk

👍 I think it looks good (and a nice addition)

glad to here that @marceloverdijk merge it if you liked it, would be an honour !!

AyushCoder9 avatar Dec 02 '25 18:12 AyushCoder9

Hi @AyushCoder9

Can you handle the comment https://github.com/honojs/hono/pull/4539#discussion_r2573092807?

If you don't react to it, we can't merge this.

yusukebe avatar Dec 03 '25 07:12 yusukebe

Hi @AyushCoder9

Can you handle the comment #4539 (comment)?

If you don't react to it, we can't merge this.

@yusukebe I've updated the PR to rename getContextIfAny to tryGetContext.

AyushCoder9 avatar Dec 03 '25 07:12 AyushCoder9

@AyushCoder9

Thank you!! We are planning to include this change in the next minor version. So, I'll merge this later!

yusukebe avatar Dec 03 '25 07:12 yusukebe

Thanks! -- I closed #4536.

elibarzilay avatar Dec 13 '25 08:12 elibarzilay