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

#8843 Clean up request data references #8883

Merged
merged 4 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Jakub Vrana](https://github.com/vrana)
- [Edvinas Pranka](https://github.com/epranka)
- [James Bromwell](https://github.com/thw0rted)
- [Brandon Nguyen](https://github.com/bn-dignitas)
9 changes: 8 additions & 1 deletion Source/Core/RequestScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ function getRequestReceivedFunction(request) {
requestCompletedEvent.raiseEvent();
request.state = RequestState.RECEIVED;
request.deferred.resolve(results);
// explicitly set to undefined to ensure GC of request response data. See #8843
request.deferred = undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

@lilleyse I have a regression introduced by this change, but it may be an unrelated bug that this is just covering up, not sure. Either way it's a RequestScheduler issue. I'm trying to create a simple reproduction now and then I'll write it up. Hopefully it's an easy fix (since you know this code way better than I do).

};
}

Expand Down Expand Up @@ -218,7 +220,12 @@ function cancelRequest(request) {
var active = request.state === RequestState.ACTIVE;
request.state = RequestState.CANCELLED;
++statistics.numberOfCancelledRequests;
request.deferred.reject();
// check that deferred has not been cleared since cancelRequest can be called
// on a finished request, e.g. by clearForSpecs during tests
if (defined(request.deferred)) {
request.deferred.reject();
request.deferred = undefined;
bn-dignitas marked this conversation as resolved.
Show resolved Hide resolved
}

if (active) {
--statistics.numberOfActiveRequests;
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -1367,9 +1367,12 @@ Resource.prototype._makeRequest = function (options) {

return promise
.then(function (data) {
// explicitly set to undefined to ensure GC of request response data. See #8843
request.cancelFunction = undefined;
bn-dignitas marked this conversation as resolved.
Show resolved Hide resolved
return data;
})
.otherwise(function (e) {
request.cancelFunction = undefined;
if (request.state !== RequestState.FAILED) {
return when.reject(e);
}
Expand Down