Skip to content

Commit

Permalink
Merge pull request #135 from taskcluster/fix-1299599
Browse files Browse the repository at this point in the history
Fix bug 1299599 - race condition between listing artifacts and listen…
  • Loading branch information
jonasfj committed Sep 6, 2016
2 parents 603d79a + ed3fa27 commit 965c9b4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 11 additions & 3 deletions lib/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ var createTaskClusterMixin = (options) => {
handleCredentialsChanged(e) {
// Update clients with new credentials
this._createClients(e.detail);

this.setState({ createdTaskIdError: null });
if (options.reloadOnLogin) {
// Reload state now that we have new credentials
Expand Down Expand Up @@ -307,10 +307,10 @@ var createTaskClusterMixin = (options) => {

return (
loggedOut403 ? (
<bs.Alert bsStyle="info">
<bs.Alert bsStyle="info">
<p>You are not authorized to perform the requested action. Please sign in and try again.</p>
</bs.Alert>
) : (
) : (
<bs.Alert bsStyle="danger">
<strong>
{code}&nbsp;
Expand Down Expand Up @@ -373,6 +373,8 @@ exports.createTaskClusterMixin = createTaskClusterMixin;
* listening: true || false || null // null when connecting
* }
* And calls `this.handleMessage(message)` when a message arrives.
* When listening is started `this.listening()` will be called if it is
* implemented.
*/
var createWebListenerMixin = (options) => {
// Set default options
Expand Down Expand Up @@ -491,6 +493,9 @@ var createWebListenerMixin = (options) => {
listening: true,
listeningError: undefined
});
if (this.listening instanceof Function) {
this.listening();
}
}, err => {
debug("Error while listening: %s, %j", err, err);
if (!err) {
Expand All @@ -514,6 +519,9 @@ var createWebListenerMixin = (options) => {
listening: true,
listeningError: undefined
});
if (this.listening instanceof Function) {
this.listening();
}
}, err => {
debug("Error while listening: %s, %j", err, err);
if (!err) {
Expand Down
8 changes: 7 additions & 1 deletion one-click-loaner/connect/connect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ let Connect = React.createClass({
];
},

listening() {
this.queue.listLatestArtifacts(this.state.taskId).then(result => {
result.artifacts.forEach(a => this.processArtifact(a, false));
}).catch(err => console.log("Failed to list artifacts: ", err));
},

handleMessage(message) {
// Update status structure
this.setState({
Expand Down Expand Up @@ -289,4 +295,4 @@ let Connect = React.createClass({
});

// Export Connect
module.exports = Connect;
module.exports = Connect;

0 comments on commit 965c9b4

Please sign in to comment.