Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Issue with canceling XHR request using promises - fixed #11035

Closed
wants to merge 489 commits into from

Conversation

netman92
Copy link
Contributor

Fixes #10890 and #9332.

@googlebot
Copy link

Thanks for your pull request.

It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/.

If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits.

Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name.

@netman92
Copy link
Contributor Author

Done

@googlebot
Copy link

CLAs look good, thanks!

@yohanh
Copy link

yohanh commented Apr 8, 2015

This fix will be add in a next version ?

@antoine-richard
Copy link

Hi

We're also experiencing this problem (#9332). See this plunker: http://plnkr.co/edit/vk9HUd?p=preview . With angular 1.2.28, it work as expected (i.e. the pending request is cancelled. I use the throttling control feature in DevTools to easily observe this).

The PR proposed here works fine for us. What is the status on this?

Please let us know if we can help you in any way.

@jtheoof
Copy link

jtheoof commented Apr 28, 2015

The patch looks good. It would be nice to get it merged in the next release. I checked the logs, I'm not sure why Travis CI is complaining.

@bborowin
Copy link
Contributor

What's the timeline on reviewing / merging this? We're hitting this problem too; made a local workaround but it would be nice to have it baked in.

@reubenbrown
Copy link

+1 to @bborowin's comment running into this issue as well. Is there a way to work around this aside from editing the ngResource code or switching back to 1.2.28?

@netman92
Copy link
Contributor Author

Can somebody merge this?

@caitp
Copy link
Contributor

caitp commented Jun 20, 2015

Looks good to me. Make sure subsequent requests can be cancelled start the first one has been,i recall there was an issue with that before

@netman92
Copy link
Contributor Author

@caitp Can you give me an example? I did not understand your answer.

@netman92 netman92 closed this Aug 7, 2015
@netman92 netman92 reopened this Aug 7, 2015
petebacondarwin and others added 11 commits August 8, 2015 12:25
Transpose "however" and "it's" on line 156 for slightly better readability

Closes angular#11686
IE7 is not supported. Also change `#template2` text to `'world'`.

Closes angular#11661
Removes the [**obsolete** HTML Teletype Text Element `<tt>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tt)
and replaces it with [`<code>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code).
This adds more semanticity and is part of the [HTML5 specification](http://www.w3.org/TR/html5/text-level-semantics.html#the-code-element).

Closes angular#11570
…s `ngRepeat`

In `ngRepeat` if the object to be iterated over is "array-like" then it only iterates
over the numerical indexes rather than every key on the object. This prevents "helper"
methods from being included in the rendered collection.

This commit changes `ngOptions` to iterate in the same way.

BREAKING CHANGE:

Although it is unlikely that anyone is using it in this way, this change does change the
behaviour of `ngOptions` in the following case:

* you are iterating over an array-like object, using the array form of the `ngOptions` syntax
(`item.label for item in items`) and that object contains non-numeric property keys.

In this case these properties with non-numeric keys will be ignored.

** Here array-like is defined by the result of a call to this internal function:
https://github.com/angular/angular.js/blob/v1.4.0-rc.1/src/Angular.js#L198-L211 **

To get the desired behaviour you need to iterate using the object form of the `ngOptions` syntax
(`value.label` for (key, value) in items)`).

Closes angular#11733
change docs for ngJq so it mentions that the placement of the directive is important with regards to the angular script.

Closes angular#11779
Closes angular#11780
caitp and others added 23 commits August 8, 2015 12:25
Previously, optional empty '='-bound expressions were ignored ---
erroneously they stopped being ignored, and no tests were caused to
fail for this reason. This change restores the original ignoring
behaviour while still preventing other errors fixed by 8a1eb16

Closes angular#12144
Closes angular#12259
Closes angular#12290
Replaces <tt> elements with <code> in expressions guide. Looks identical
in Chromium

Closes angular#12437
…tener

The previous explanation in parentheses created a bit of confusion because the documentation stated to leave off the `listener`, but then said "be prepared for multiple calls to your listener". The new explanation clarifies that it is indeed the `watchExpression` that will be executed multiple times.

Closes angular#12429
Previously there was a custom built en-us locale that was included with
angular.js. This made likely that it would get out of sync with the real
en-us locale that is generated from the closure library.

This change removes that custom one and uses the generated one instead.
This also has the benefit of preventing the unwanted caught error on trying
to load `ngLocale` during angular bootstrap.

Closes angular#12462
Closes angular#12444
Closes angular#12134
Closes angular#8174
The legacy methods, `success` and `error`, have been deprecated.

Set this to `false` to cause `$http` to throw an error if these methods are
used in the application.

For now it defaults to `true`. In a future release we will remove these
methods altogether.

DEPRECATION NOTICE:

The legacy methods 'success' and 'error' on promises returned by $http
are now deprecated.

Closes angular#12112
Closes angular#10508
Close select element in html example to stop errors occurring for copy/paste users

Closes angular#12384
When users accidentally just pass a single string, e.g.
`angular.injector('myModule')`, this change give them a better error message.

Currently Angular just reports that the module with the name 'm' is missing,
as it's iterating through all characters in the string, instead of all strings
in the module.

Closes angular#12285
It will be good to have the binding results in the CSS classes /
binding to form / control state example, similar to the Simple Form
example.

Closes angular#12326
The versions are updated in the angular-phonecat repo, but not in
the documentation. This change syncs the version numbers.

Closes angular#12396
The original file included a code sample using `angular.injector(['myModule', 'ng'])`,
which appears to be incorrect when trying to retrieve anything attached to `myModule`.
Reversing the args fixes this.

Closes angular#12292
The removed line pointed to a removed example. Re-adding the example
would have been of questionable value, as it introduced several
concepts without context. It's therefore better to link to the guide,
which provides a better introduction.

Closes angular#12167
Summary:
  - Use properly capitalized GitHub brand name
  - Correctly negate two clauses using "nor" (caitp feels this may confuse
non-english speakers and need to be revised, but hopefully not)
  - Correctly end sentence with period

Closes angular#12497
Adding missing semi-colon which is breaking minification

Closes angular#12513
Escape the wide char quote marks in a regex in linky.js

Closes angular#11609
Remove the private `setter` function from $parse
Replace the `setter` from the `form` directive with $parse

Closes angular#12483
@okiss
Copy link

okiss commented Aug 20, 2015

Hi @caitp
I created a jsbin example (From PR #12525 ) to show how this fix works. Please have a look at http://jsbin.com/hoxuhotupe/edit?html,js,console,output

If multiple requests are running, resolving the promise will cancel them all (Try clicking the 'create button' multiple times quickly and then click the 'cancel request' button. See the console output).

After you cancel a request, you can create a new request and it will not be interrupted. (Click the 'create request' button, then click the 'cancel request' button. Click the 'create request' button again and wait a few seconds. See that the request completed successfully).

This is the same behavior as was present in 1.2.x. It would be very helpful if the regression was fixed.

@caitp
Copy link
Contributor

caitp commented Aug 20, 2015

this PR has gotten extremely hard to understand, I'm not entirely sure which comments apply to the pr/issue and which ones apply to the other commits. Do you think you (@netman92) could rebase this and force push just so it's easier to read?

@okiss
Copy link

okiss commented Aug 20, 2015

@caitp see #12525 . It contains just the relevant commit

@caitp
Copy link
Contributor

caitp commented Aug 20, 2015

Okay, thanks for the verification @okiss. The diff/PR/@netman92's master branch has gotten really screwed up and the PR has been closed, so it can't really be reviewed or merged.

@jtheoof
Copy link

jtheoof commented Aug 21, 2015

What about the #12525 ? It is more recent, is it messed up as well?

@caitp
Copy link
Contributor

caitp commented Aug 21, 2015

Probably, it's the master branch, bad idea

@jtheoof
Copy link

jtheoof commented Aug 23, 2015

@caitp Can you have a look at #12657. @netman92 has rebased properly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.