Skip to content
This repository has been archived by the owner on Oct 6, 2021. It is now read-only.

Commit

Permalink
Handle event polling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nhynes committed Jul 29, 2020
1 parent 875abba commit 5f7b254
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/gateway/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,12 @@ class HttpGateway implements OasisGateway {
url: this.url,
session: this.session,
queueId: response.id,
}).subscribe(response.id, (event: any) => {
events.emit(request.event, event);
}).subscribe(response.id, (err: any, event: any) => {
if (err) {
events.emit('error', err);
} else {
events.emit(request.event, event);
}
});
return events;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/gateway/src/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ export default class PollingService {
if (this.polling) {
throw new Error('cannot make a new subscription when already polling');
}
this.responses.addListener(SubscribeTopic, callback);
this.responses.on(SubscribeTopic, (event: any) => callback(null, event));
this.responses.on('error', (err: any) => callback(err));
this.start();
}

Expand Down

0 comments on commit 5f7b254

Please sign in to comment.