Skip to content

Commit

Permalink
Merge pull request #91 from bhikadiyajatin/master
Browse files Browse the repository at this point in the history
Adding fix to reduce intermittent "Initialization failed" and "Missed call" issues
  • Loading branch information
jaswinderAws authored Jan 9, 2019
2 parents 158e11d + f3a5c89 commit afc3a10
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
self.portConduitMap[stream.getId()] = portConduit;

if (self.agent !== null) {
portConduit.sendDownstream(connect.AgentEvents.UPDATE, self.agent);
self.updateAgent();
}

portConduit.onDownstream(connect.EventType.API_REQUEST,
Expand All @@ -218,14 +218,19 @@
timeout: GET_AGENT_TIMEOUT_MS
}, {
success: function(data) {
self.agent = self.agent || {};
self.agent.snapshot = data.snapshot;
self.agent.snapshot.localTimestamp = connect.now();
self.agent.snapshot.skew = self.agent.snapshot.snapshotTimestamp - self.agent.snapshot.localTimestamp;
self.nextToken = data.nextToken;
connect.getLog().trace("GET_AGENT_SNAPSHOT succeeded.").withObject(data);
self.updateAgent();
global.setTimeout(connect.hitch(self, self.pollForAgent), GET_AGENT_SUCCESS_TIMEOUT_MS);
try {
self.agent = self.agent || {};
self.agent.snapshot = data.snapshot;
self.agent.snapshot.localTimestamp = connect.now();
self.agent.snapshot.skew = self.agent.snapshot.snapshotTimestamp - self.agent.snapshot.localTimestamp;
self.nextToken = data.nextToken;
connect.getLog().trace("GET_AGENT_SNAPSHOT succeeded.").withObject(data);
self.updateAgent();
} catch(e) {
connect.getLog().error("Long poll failed to update agent.").withObject(data).withException(e);
} finally {
global.setTimeout(connect.hitch(self, self.pollForAgent), GET_AGENT_SUCCESS_TIMEOUT_MS);
}
},
failure: function(err, data) {
try {
Expand Down

0 comments on commit afc3a10

Please sign in to comment.