-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix resumable upload error "There was a problem uploading your video" #1001
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@phaizullin Thanks for your contribution! |
@yguedidi Firstly, because it is mostly facebook internal error, it want to process another chunk (mostly random chunk) after processing current chunk, but uploadVideo method retry only current chunk and it returns same error 5 times via maxTriesTransfer method. |
I am also experiencing the same problems, it would be nice for this fix to get merged. |
This is an important patch. What's the hold up in the merge or further comments? |
This seems to be a common issue so I'd be +1 for merging. For the record, the error message for
The recommendation is:
@phaizullin & @yguedidi Assuming we merge this in - we should probably figure out how this impacts the max retires. This PR technically adds a non-deterministic outcome as there is an edge case where Graph returns the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phaizullin Thanks for the PR! Can we also add a test to show this functionality works? Once we get these things tweaked, we can merge this in. :)
$chunk->getFile(), | ||
$chunk->getUploadSessionId(), | ||
$chunk->getVideoId(), | ||
$e->getResponseData()['error']['error_data']['start_offset'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably do some isset()
checks on this and the next line just in case Graph changes the error data structure it responds with.
@@ -121,6 +121,16 @@ public function transfer($endpoint, FacebookTransferChunk $chunk, $allowToThrow | |||
throw $e; | |||
} | |||
|
|||
if ($e->getSubErrorCode() === 1363037) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make 1363037
a class constant. :)
@phaizullin @SammyK I'm not that against this PR, I'm more against the implementation. Let met explian: This solution looks more like a quick workaround to the issue. How I conceptualy see it is more: you should catch a specific exception, that will give you access to a Enforcing an error handling internally looks bad to me. An SDK responsability is to provide the more detailed error, while handle it is user's code responsability: an SDK shouldn't has error no? :) |
@yguedidi what you're saying makes sense, however the current pattern the SDK sets up with the "super" Facebook class is that the client has a minimum amount of information about the upload process. If the FB SDK expects the calling client to handle chunks and errors (not a bad idea), it should expose more methods to allow an efficient way of doing this. The only public method in the Facebook class at the moment is "uploadVideo". In the meanwhile, is there another recommendation on working around this issue? |
@abhishekbh You could work directly with the |
How I see things:
I see the proposed fix (return the retryable chunk), as one of those cool feature, so I think it should live in the |
@yguedidi It is't entirely clear from your words what changes in the PR are needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's accept this solution and move forward! it still can be refactored for v6.
please rebase, fix review and update the changelog
$previousException = new FacebookResumableUploadException($message, $code); | ||
|
||
$startOffset = isset($data['error']['error_data']['start_offset']) ? | ||
$data['error']['error_data']['start_offset'] : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep this in the same line. BTW, you should cast to int the offset
$previousException->setStartOffset($startOffset); | ||
|
||
$endOffset = isset($data['error']['error_data']['end_offset']) ? | ||
$data['error']['error_data']['end_offset'] : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep this in the same line. BTW, you should cast to int the offset
protected $endOffset; | ||
|
||
/** | ||
* @return int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int|null
} | ||
|
||
/** | ||
* @param int $startOffset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int|null
} | ||
|
||
/** | ||
* @return int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int|null
} | ||
|
||
/** | ||
* @param int $endOffset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int|null
@@ -121,6 +121,16 @@ public function transfer($endpoint, FacebookTransferChunk $chunk, $allowToThrow | |||
throw $e; | |||
} | |||
|
|||
if (!is_null($preException->getStartOffset()) && !is_null($preException->getEndOffset())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer !== null
instead of is_null
|
||
$chunk = new FacebookTransferChunk($this->file, '1', '2', '3', '4'); | ||
$newChunk = $uploader->transfer('/me/videos', $chunk); | ||
$this->assertEquals('40', $newChunk->getStartOffset()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please assert also on the end ofset
@phaizullin please rebase so that only your commit appear in the diff |
@phaizullin any news? |
… Please try again.
…or resumable upload.
Thank you @phaizullin |
And congrats for you first contribution to the SDK @phaizullin, I can't wait for your other pull requests! |
Changed start_offset and end_offset from error code as written in documentation