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(cache): fix event handler integrity hash generation #1820

Merged
merged 4 commits into from
Oct 19, 2023

Conversation

yassilah
Copy link
Contributor

πŸ”— Linked issue

In reference to: #1813 (comment)

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR resolves an issue when setting cache integrity as an array.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@yassilah
Copy link
Contributor Author

yassilah commented Oct 11, 2023

Thanks for PR dear @yassilah. I will have to locally verify your reproduction from #1812. In the meantime, if there is another fix for integrity, feel free to split it into new PR for better changelog.

Actually, taking a look at #1791 you're referencing, I don't think the change I made has any effect:
https://github.com/unjs/nitro/blob/ae253596a847f764e275f7e0450ffdfcdcd8957e/src/runtime/cache.ts#L54

You allowed the opts.integrity value to checked against entry.integrity, which is still the case in #1813. However, the issue came from this line, which makes opts.integrity an array:
https://github.com/unjs/nitro/blob/ae253596a847f764e275f7e0450ffdfcdcd8957e/src/runtime/cache.ts#L257

And that will necessarily fail here, since entry.integrity can only be a string:
https://github.com/unjs/nitro/blob/ae253596a847f764e275f7e0450ffdfcdcd8957e/src/runtime/cache.ts#L78

So, actually this PR should fix a potential regression introduced by #1791

@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

Merging #1820 (5a175a8) into main (c4c0046) will not change coverage.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##             main    #1820   +/-   ##
=======================================
  Coverage   52.36%   52.36%           
=======================================
  Files         170      170           
  Lines       11775    11775           
  Branches      907      907           
=======================================
  Hits         6166     6166           
  Misses       5513     5513           
  Partials       96       96           
Files Coverage Ξ”
src/runtime/cache.ts 0.00% <0.00%> (ΓΈ)

src/runtime/cache.ts Outdated Show resolved Hide resolved
@pi0 pi0 changed the title fix(cache): turn default integrity to hash fix(cache): fix event handler integrity hash generation Oct 19, 2023
@pi0 pi0 merged commit 3e9302a into nitrojs:main Oct 19, 2023
7 of 8 checks passed
@yassilah yassilah deleted the fix-integrity-check branch October 19, 2023 11:35
@pi0 pi0 mentioned this pull request Oct 19, 2023
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.

2 participants