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(middleware): cache grows even if no middleware created #8674

Merged
merged 5 commits into from
Jul 6, 2024

Conversation

BrainCrumbz
Copy link
Contributor

Description

See issue #8653

Specific Changes proposed

When in middleware.js the function clearCacheForPlayer runs, before setting a value to null in middlware caches, it checks if the key exists in the first place.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chrome, Firefox, IE)
    • Unit Tests updated or fixed
    • Docs/guides updated
    • Example created (starter template on JSBin)
  • Reviewed by Two Core Contributors

@BrainCrumbz
Copy link
Contributor Author

BTW, we're contributing to this on Windows, and still suffer from issue #8149. To make that work, we temporarily modified package.json

@BrainCrumbz
Copy link
Contributor Author

We noticed from e-mails some repeated failure on that CI task. I guess, that is not related to the specific changes in code, is it?

@@ -244,7 +244,9 @@ function executeRight(mws, method, value, terminated) {
* A {@link Player} instance.
*/
export function clearCacheForPlayer(player) {
middlewareInstances[player.id()] = null;
if (middlewareInstances.hasOwnProperty(player.id())) {
middlewareInstances[player.id()] = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if delete is preferable, if the object having null properties was the issue being addressed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the issue being addressed is that middlewareInstances grows with new keys having null values. Not sure why the original code prefers setting to null instead of deleting.

Just as a speculation: in player.js there's the global enumeration of players, Player.players, and in that case it is explicitly mentioned that a disposed player should be left as a key with null value. Maybe that same behaviour has been applied in middlewareInstances, even if there is no actual use of it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go with delete here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, commit is pushed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure if - at this point - code should just delete without checking whether middlewareInstances has that property or not.

@mister-ben
Copy link
Contributor

We noticed from e-mails some repeated failure on that CI task. I guess, that is not related to the specific changes in code, is it?

No, I tried re-running the failing test a few times. Upload to codecov is inexplicably flaky, even when a CODECOV_TOKEN token is used.

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.01%. Comparing base (6b468dd) to head (9c116f1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8674   +/-   ##
=======================================
  Coverage   83.01%   83.01%           
=======================================
  Files         119      119           
  Lines        7993     7994    +1     
  Branches     1923     1924    +1     
=======================================
+ Hits         6635     6636    +1     
  Misses       1358     1358           

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

@BrainCrumbz
Copy link
Contributor Author

Hi there. Just to let you know: if there's something more to do on our side, we might be able to.
Kind regards

@mister-ben mister-ben added the needs: LGTM Needs one or more additional approvals label Jun 21, 2024
@mister-ben mister-ben removed the needs: LGTM Needs one or more additional approvals label Jul 6, 2024
@mister-ben mister-ben merged commit 6221a8f into videojs:main Jul 6, 2024
11 checks passed
@BrainCrumbz BrainCrumbz deleted the issue-8653 branch July 8, 2024 07:33
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.

None yet

4 participants