🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@jbedard
Copy link
Contributor

@jbedard jbedard commented May 4, 2017

Fixes #3606

I'm not sure why we need both callbacks and .then handlers. Could we instead merge those Callbacks? EDIT: I think it's because error handling works different?

@mention-bot
Copy link

@jbedard, thanks for your PR! By analyzing the history of the files in this pull request, we identified @gibson042, @jaubourg and @markelog to be potential reviewers.

@markelog
Copy link
Member

markelog commented May 8, 2017

No tests? There is also code-style issue

@jbedard
Copy link
Contributor Author

jbedard commented May 8, 2017

I wasn't really sure how this could be unit tested. Any ideas? With everything hidden in closures it's a little hard to do things like spy on the callback methods...

@timmywil timmywil added this to the 3.3.0 milestone May 15, 2017
@timmywil timmywil requested a review from gibson042 June 5, 2017 15:34
src/deferred.js Outdated
tuples[ 0 ][ 2 ].lock
);

tuple[ 3 ].add(
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look right to me; I think we should do everything in the existing handler (i.e., it should disable both done callbacks and then callbacks, and lock both done and then progress notifications). We could probably also stand to improve the comments, since "callbacks" is ambiguous in light of done vs. then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean adding it to the list.add above? I'll try it out... I don't recall why I did it here :/

@gibson042
Copy link
Member

I'm not sure why we need both callbacks and .then handlers. Could we instead merge those Callbacks? EDIT: I think it's because error handling works different?

Yes, among other reasons. .done callbacks fire synchronously and can lock up, but the first thing they do is kick off asynchronous .then callbacks (which can't).

@jbedard
Copy link
Contributor Author

jbedard commented Jun 9, 2017

@gibson042 I've moved everything into the existing list.add call.

Copy link
Member

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

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

LGTM

jbedard added a commit to jbedard/jquery that referenced this pull request Jun 13, 2017
@jbedard
Copy link
Contributor Author

jbedard commented Jun 14, 2017

Interesting... I amended the commit just to add the PR number to the commit msg and one test started failing. Now I ran it again and everything passed. Anyone ever see something similar before? I can't seem to reproduce it locally.

Here's the travis job that failed: https://travis-ci.org/jquery/jquery/jobs/242269140

The test failure:

  1) 2.2.6: `then` may be called multiple times on the same promise. 2.2.6.2: If/when `promise` is rejected, all respective `onRejected` callbacks must execute in the order of their originating calls to `then`. `onRejected` handlers are called in the original order even when one handler is added inside another handler immediately-rejected:
     Uncaught AssertError: expected handler1, handler2, handler3 to be called in order but were called as handler1, handler2
      at Object.fail (node_modules/sinon/lib/sinon/assert.js:90:29)
      at failAssertion (node_modules/sinon/lib/sinon/assert.js:51:24)
      at Object.assertCallOrder [as callOrder] (node_modules/sinon/lib/sinon/assert.js:118:21)
      at null._onTimeout (node_modules/promises-aplus-tests/lib/tests/2.2.6.js:249:42)

@gibson042 gibson042 merged commit 3638928 into jquery:master Jun 20, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants