Fix(nodejs/event_dispatcher): update error/resp handlers#123
Merged
tylerbrandt merged 6 commits intomasterfrom Jun 25, 2018
Merged
Fix(nodejs/event_dispatcher): update error/resp handlers#123tylerbrandt merged 6 commits intomasterfrom
tylerbrandt merged 6 commits intomasterfrom
Conversation
tylerbrandt
commented
Jun 22, 2018
| }); | ||
| }); | ||
|
|
||
| it('calls callback with err when one is emitted', function(done) { |
Contributor
Author
There was a problem hiding this comment.
Note: before changing the event_dispatcher code, the .dispatchEvent call did indeed throw an error.
mikeproeng37
suggested changes
Jun 22, 2018
Contributor
mikeproeng37
left a comment
There was a problem hiding this comment.
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
spencerwilson-optimizely
approved these changes
Jun 22, 2018
tylerbrandt
pushed a commit
that referenced
this pull request
Jun 25, 2018
- (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
tylerbrandt
pushed a commit
that referenced
this pull request
Jun 25, 2018
- (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
tylerbrandt
pushed a commit
that referenced
this pull request
Jun 25, 2018
- (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
tylerbrandt
pushed a commit
that referenced
this pull request
Jun 25, 2018
* 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
tylerbrandt
pushed a commit
that referenced
this pull request
Jun 25, 2018
* 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
Closed
Closed
Closed
Closed
Closed
This was referenced Dec 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
http/httpsemits an error by adding an 'error' listenerrequestCallbackto 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