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

Try to catch and log errors during upload #1283

Merged
merged 5 commits into from
Mar 23, 2024
Merged

Try to catch and log errors during upload #1283

merged 5 commits into from
Mar 23, 2024

Conversation

kueda
Copy link
Member

@kueda kueda commented Mar 13, 2024

  • Wraps some upload async methods with try/catch to attempt to log some potential bugs
  • Adjusts upload param mappings
  • Try to get upload status to more accurately reflect the upload state

* Wraps some upload async methods with try/catch to attempt to log some
  potential bugs
* Adjusts upload param mappings
* Try to get upload status to more accurately reflect the upload state
@kueda kueda requested a review from jtklein March 13, 2024 04:38
if ( numUnuploadedObs && numUnuploadedObs !== 0 ) {
return t( "Upload-x-observations", { count: numUnuploadedObs } );
}

Copy link
Member Author

Choose a reason for hiding this comment

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

This might be a bit off spec, but if you upload one of several obs, I think it should say there are still obs to upload when it's done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

When this branched off the "Upload success" message was sticking around forever, current main is it will disappear after 5s and then the "Upload x observations" state will reappear if there are numUnuploadedObs !== 0 . The way I handled it in my PR is to reset the upload state and therefore set uploadsComplete to false after 5s. With your changes, it will switch back to "Upload x observations" immediately. I am fine with merging this in if it seems more appropriate UX.

Copy link
Member Author

Choose a reason for hiding this comment

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

I like your approach better, and I think that's what Abhas wants. I merged from main and tried to get the single-upload case to have that 5s delay as well.

"photo[uuid]": observationPhoto.uuid,
photo: {
id: observationPhoto.photo.id
},
Copy link
Member Author

Choose a reason for hiding this comment

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

Sending the ObservationPhoto UUID instead of the Photo UUID is dangerous here, because they will be different in server responses. The server doesn't seem to respond with the photo UUID at all, which is a separate problem.

uuid: mockPhoto.uuid
}] ) );
} );

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why this was working, but I'm pretty sure it was not actually integrating the API wrappers and related networking code. This mocks inatjs responses to make sure that when those parts of the app get exercised they get reasonable responses.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it make sense to have those mocks in the inaturalistjs package itself? Would other clients benefit if we have a shared mock?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure. Here the mock implementation is very specific to the test, like we want it to return very specific values. If inatjs were to have built-in mocks, they'd probably need to return generic mock data, so in this case we'd still need to make our own implementation. There might be other cases where that would be useful, though.

@kueda
Copy link
Member Author

kueda commented Mar 13, 2024

@jtklein I haven't had a chance to test this thoroughly under field conditions, but I got a bit into the upload code which I know you worked on recently, so I'd appreciate it if you could take a glance and see if anything seems glaringly wrong.

Copy link
Collaborator

@jtklein jtklein left a comment

Choose a reason for hiding this comment

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

Have started to review but when I upload an observation I am hitting this every time, and the upload does not finish:

LOG  2024-03-13T12:03:18.495Z | INatApiError | ERROR : Error requesting https://stagingapi.inaturalist.org/v2/observation_photos (status: 422):
    {"status":"422","errors":[{"errorCode":"422","message":{"errors":"No photo specified"},"from":"externalAPI"}]}

This would need to be fixed before I can continue.

@kueda kueda requested a review from jtklein March 21, 2024 17:57
Copy link
Collaborator

@jtklein jtklein left a comment

Choose a reason for hiding this comment

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

Overwhelmingly good to go I would say. Could not see anything glaringly off.

if ( numUnuploadedObs && numUnuploadedObs !== 0 ) {
return t( "Upload-x-observations", { count: numUnuploadedObs } );
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

When this branched off the "Upload success" message was sticking around forever, current main is it will disappear after 5s and then the "Upload x observations" state will reappear if there are numUnuploadedObs !== 0 . The way I handled it in my PR is to reset the upload state and therefore set uploadsComplete to false after 5s. With your changes, it will switch back to "Upload x observations" immediately. I am fine with merging this in if it seems more appropriate UX.

src/realmModels/ObservationPhoto.js Outdated Show resolved Hide resolved
@kueda kueda merged commit 97fd4f2 into main Mar 23, 2024
14 checks passed
@kueda kueda deleted the catch-upload-errors branch March 23, 2024 02:17
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