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

FileLoader: Incorrect error handling. #22925

Merged
merged 4 commits into from
Dec 4, 2021
Merged

Conversation

leyiang
Copy link
Contributor

@leyiang leyiang commented Nov 30, 2021

Related issue: Fixed #22923

Description

Once the fetch of FileLoader is fulfilled, url will be deleted in loading object.
If there are any error being throwed inside the onLoad callback, catch function of the fetch will throw confusing error message instead of real error.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 1, 2021

@gkjohnson Does this PR look good to you?

if ( callbacks === undefined ) {

// When onLoad was called and url was deleted in `loading`
this.manager.itemError( url );
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to fire this.manager.itemEnd( url ); here as it does at the end of the "catch" block, too

Copy link
Collaborator

@Mugen87 Mugen87 Dec 1, 2021

Choose a reason for hiding this comment

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

In the reported use case itemEnd() would be executed twice then. At this place and in the previous then() block.

Copy link
Collaborator

@gkjohnson gkjohnson Dec 2, 2021

Choose a reason for hiding this comment

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

I don't think that's the case. If an error is thrown in the promise callbacks and the catch callback is run then the above itemEnd will not be hit. And either way the catch function already calls the itemEnd function at the bottom of it (line 218) so it should be called in this new branch too for consistency.

Another option would be to call itemEnd in a ".finally" callback, instead, so it always gets run

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another option would be to call itemEnd in a ".finally" callback, instead, so it always gets run

That sounds like the cleanest solution to me.

Copy link
Contributor Author

@leyiang leyiang Dec 4, 2021

Choose a reason for hiding this comment

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

Done!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great! I think this looks right to me, now!

@leyiang leyiang changed the title fix. FileLoader not showing correct error message when onLoad throws errors FileLoader: Incorrect error handling. Dec 3, 2021
@Mugen87 Mugen87 added this to the r136 milestone Dec 4, 2021
@mrdoob mrdoob merged commit f2f55dd into mrdoob:dev Dec 4, 2021
@mrdoob
Copy link
Owner

mrdoob commented Dec 4, 2021

Thanks!

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.

FileLoader: Incorrect error handling.
4 participants