Closed aestes closed 5 years ago
+@marcoscaceres
Thinking about it, it seems like the spec does need changing. The specified behavior allows for a weird situation where the user can accept a payment that the merchant can never properly complete.
If we want calling complete() while a retry promise is pending to be a fatal error, then I think we need to reject the retry promise and close down the UI in addition to setting complete to true.
If we want it to be non-fatal, then I think the right fix is to throw an InvalidStateError when there is a retry promise but not set complete to true until right before the "in parallel" steps start executing.
(I'm partial to it being non-fatal.)
Thanks for all the details. Let’s fix this up during TPAC.
I went with the non-fatal option in the PR :) Well spotted, btw!
I'm working on implementing payment retry in WebKit, and I'm seeing an unexpected failure when running retry-method-manual.https.html:
I think I've implemented complete() as-specified, so I'm not sure whether the test is wrong or the spec is.
What's happening in the test is:
response.retry()
.response.[[retryPromise]]
to a new promise.response.complete("success")
.response.[[complete]]
totrue
.InvalidStateError
becauseresponse.[[retryPromise]]
is not null.response.[[retryPromise]]
.response.complete("success")
.InvalidStateError
again, this time becauseresponse.[[complete]]
istrue
. It's this exception that generates the failure mentioned above.The test seems to expect that response should remain non-complete after the first call to
complete()
and therefore the second call tocomplete()
should succeed since the retry promise had settled.The spec says that
response.[[complete]]
should be set totrue
before checking ifresponse.[[retryPromise]]
is non-null. So that means the second call tocomplete()
must throw anInvalidStateError
even ifresponse.[[retryPromise]]
had been settled.Should we defer setting
response.[[complete]]
totrue
until later in the algorithm? Or should we change the test to expect an exception on the second call tocomplete()
?