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(preload): Fix error handling #6753

Merged
merged 8 commits into from
Jun 4, 2024

Conversation

theodab
Copy link
Contributor

@theodab theodab commented Jun 4, 2024

After a previous bugfix to the preload system, we ended up with a situation where the
overall progress in the preload was tracked by two promises:
successPromise_, which is resolved when the preload finishes successfully.
destroyPromise_, which is rejected with an error when the preload process trips an error condition.
These two promises were confusingly named; it sounds like destroyPromise is related to the destroy process,
but really it has more to do with errors.
They were also completely redundant, as a single promise can be used to carry both a resolved and
rejected state.

This PR simply combines the two promises into one.

Previously, preload errors were passed through the destroyPromise,
which is contrary to our normal practices.
@theodab theodab added the type: bug Something isn't working correctly label Jun 4, 2024
@theodab theodab requested a review from joeyparrish June 4, 2024 18:16
@theodab
Copy link
Contributor Author

theodab commented Jun 4, 2024

Actually, thinking about this some more, now that I have added successPromise_, destroyPromise_ doesn't really do anything anymore. It'd probably be better to just remove it, it was a sort of misleadingly named variable anyway.

Comment on lines 137 to 138
// Silence promise failures, in case nobody is catching this.successPromise_
this.successPromise_.catch((error) => {});
Copy link
Member

Choose a reason for hiding this comment

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

This is the only part I'm unsure of. It might mask important errors. Do we need this for our demo or tests? Or is it just preventative somehow?

Copy link
Contributor Author

@theodab theodab Jun 4, 2024

Choose a reason for hiding this comment

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

It's required for the tests.

I just tried this out to remind myself, and without this some of the tests fail. It complains about uncaught promise rejections.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should fix the tests, then, to catch any preload manager errors. Even if it's just silenced in the test case, that's better, I think, than silencing it globally in the library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we might be able to change the tests instead? I'm not sure how many tests are broken because apparently an uncaught promise failure in afterAll causes the entire test run to stop, for whatever reason.

Copy link
Member

Choose a reason for hiding this comment

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

I'll take a stab at it.

Copy link
Member

Choose a reason for hiding this comment

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

I tested with:

./build/test.py --browsers Chrome \
  --no-babel \
  --uncompiled \
  --delay-tests 2

--delay-tests helped make errors after tests clearer by inserting a delay between each case. After narrowing it down to Player unit tests, I found out the problem was in start() and waitForFinish() returning two technically separate promises that resolve/reject on the same events/values. Clarifying that so that start() initiates the action only, makes it so that Player is catching errors in all the right places.

@theodab theodab changed the title fix(preload): Pass errors through successPromise. fix(preload): Combine successPromise and destroyPromise Jun 4, 2024
@shaka-bot
Copy link
Collaborator

shaka-bot commented Jun 4, 2024

Incremental code coverage: 100.00%

@avelad avelad added the priority: P2 Smaller impact or easy workaround label Jun 4, 2024
@avelad avelad added this to the v4.10 milestone Jun 4, 2024
@joeyparrish
Copy link
Member

@theodab please merge if you approve of the change I made

@joeyparrish
Copy link
Member

Looks like it's failing a test... my bad

@theodab
Copy link
Contributor Author

theodab commented Jun 4, 2024

I can't approve this since it's technically still my own PR, but I've looked over Joey's change and approve of it. I think we can now submit this, once it passes a full test run.

@joeyparrish joeyparrish changed the title fix(preload): Combine successPromise and destroyPromise fix(preload): Fix error handling Jun 4, 2024
@joeyparrish joeyparrish merged commit 9d1fe4a into shaka-project:main Jun 4, 2024
14 of 15 checks passed
joeyparrish added a commit that referenced this pull request Jun 4, 2024
After a previous bugfix to the preload system, we ended up with a
situation where the
overall progress in the preload was tracked by two promises:
`successPromise_`, which is resolved when the preload finishes
successfully.
`destroyPromise_`, which is rejected with an error when the preload
process trips an error condition.
These two promises were confusingly named; it sounds like destroyPromise
is related to the destroy process,
but really it has more to do with errors.
They were also completely redundant, as a single promise can be used to
carry both a resolved and
rejected state.

This PR simply combines the two promises into one.

---------

Co-authored-by: Joey Parrish <[email protected]>
joeyparrish added a commit that referenced this pull request Jun 4, 2024
After a previous bugfix to the preload system, we ended up with a
situation where the
overall progress in the preload was tracked by two promises:
`successPromise_`, which is resolved when the preload finishes
successfully.
`destroyPromise_`, which is rejected with an error when the preload
process trips an error condition.
These two promises were confusingly named; it sounds like destroyPromise
is related to the destroy process,
but really it has more to do with errors.
They were also completely redundant, as a single promise can be used to
carry both a resolved and
rejected state.

This PR simply combines the two promises into one.

---------

Co-authored-by: Joey Parrish <[email protected]>
@theodab theodab deleted the preloadErrorFixBranchToo branch June 4, 2024 23:45
joeyparrish added a commit that referenced this pull request Jun 5, 2024
After a previous bugfix to the preload system, we ended up with a
situation where the
overall progress in the preload was tracked by two promises:
`successPromise_`, which is resolved when the preload finishes
successfully.
`destroyPromise_`, which is rejected with an error when the preload
process trips an error condition.
These two promises were confusingly named; it sounds like destroyPromise
is related to the destroy process,
but really it has more to do with errors.
They were also completely redundant, as a single promise can be used to
carry both a resolved and
rejected state.

This PR simply combines the two promises into one.

---------

Co-authored-by: Joey Parrish <[email protected]>
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Aug 3, 2024
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Aug 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants