-
Notifications
You must be signed in to change notification settings - Fork 83
Fix(nodejs/event_dispatcher): update error/resp handlers #123
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
Conversation
@@ -98,5 +98,18 @@ describe('lib/plugins/event_dispatcher/node', function() { | |||
eventDispatcher.dispatchEvent(eventObj, callback); | |||
}); | |||
}); | |||
|
|||
it('calls callback with err when one is emitted', function(done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: before changing the event_dispatcher code, the .dispatchEvent
call did indeed throw an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to handle the err on the caller here: https://github.com/optimizely/javascript-sdk/blob/master/packages/optimizely-sdk/lib/optimizely/index.js#L192
And log the fact that and error occurred. Otherwise the SDK is going to pretend the call was successful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it
- (nodejs) Prevent crash when `http`/`https` emits an error by adding an 'error' listener - (nodejs) Fix `requestCallback` to conform to its role as a 'response' listener; notably, ensure it is called when the first argument is interpeted as the `http.IncomingMessage`, and _not_ called in the event of an error (as expected by `Optimizely#_sendImpressionEvent`/`Optimizely#track`). Tested that this version (as 2.1.2-0) _does_ emit the messages expected in the demo app. Fixes #122 Fixes #124
- (nodejs) Prevent crash when `http`/`https` emits an error by adding an 'error' listener - (nodejs) Fix `requestCallback` to conform to its role as a 'response' listener; notably, ensure it is called when the first argument is interpeted as the `http.IncomingMessage`, and _not_ called in the event of an error (as expected by `Optimizely#_sendImpressionEvent`/`Optimizely#track`). Tested that this version (as 2.1.2-0) _does_ emit the messages expected in the demo app. Fixes #122 Fixes #124
- (nodejs) Prevent crash when `http`/`https` emits an error by adding an 'error' listener - (nodejs) Fix `requestCallback` to conform to its role as a 'response' listener; notably, ensure it is called when the first argument is interpeted as the `http.IncomingMessage`, and _not_ called in the event of an error (as expected by `Optimizely#_sendImpressionEvent`/`Optimizely#track`). Tested that this version (as 2.1.2-0) _does_ emit the messages expected in the demo app. Fixes #122 Fixes #124 # Conflicts: # packages/optimizely-sdk/lib/plugins/event_dispatcher/index.node.js # packages/optimizely-sdk/lib/plugins/event_dispatcher/index.node.tests.js
* Fix(nodejs/event_dispatcher): update error/resp handlers (#123) - (nodejs) Prevent crash when `http`/`https` emits an error by adding an 'error' listener - (nodejs) Fix `requestCallback` to conform to its role as a 'response' listener; notably, ensure it is called when the first argument is interpeted as the `http.IncomingMessage`, and _not_ called in the event of an error (as expected by `Optimizely#_sendImpressionEvent`/`Optimizely#track`). Tested that this version (as 2.1.2-0) _does_ emit the messages expected in the demo app. Fixes #122 Fixes #124
* Fix(nodejs/event_dispatcher): update error/resp handlers (#123) - (nodejs) Prevent crash when `http`/`https` emits an error by adding an 'error' listener - (nodejs) Fix `requestCallback` to conform to its role as a 'response' listener; notably, ensure it is called when the first argument is interpeted as the `http.IncomingMessage`, and _not_ called in the event of an error (as expected by `Optimizely#_sendImpressionEvent`/`Optimizely#track`). Tested that this version (as 2.1.2-0) _does_ emit the messages expected in the demo app. Fixes #122 Fixes #124
http
/https
emits an error by adding an 'error' listenerrequestCallback
to conform to its role as a 'response' listener; notably, ensure it is called when the first argument is interpeted as thehttp.IncomingMessage
, and not called in the event of an error (as expected byOptimizely#_sendImpressionEvent
/Optimizely#track
).Tested that this version (as 2.1.2-0) does emit the messages expected in the demo app.
Fixes #122
Fixes #124