Skip to content

(nodejs) Failure to log "success" message when event dispatched #124

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

Closed
tylerbrandt opened this issue Jun 22, 2018 · 0 comments
Closed

(nodejs) Failure to log "success" message when event dispatched #124

tylerbrandt opened this issue Jun 22, 2018 · 0 comments

Comments

@tylerbrandt
Copy link
Contributor

Since #98, the requestCallback never gets called with a second argument, because its role is a 'response' handler for HttpClientRequest:

The optional callback parameter will be added as a one-time listener for the 'response' event.
src: https://nodejs.org/api/http.html#http_http_request_options_callback

As a result, the callback defined in __dispatchEvent currently never gets called in nodejs, and as a result we don't log any messages for LOG_MESSAGES.ACTIVATE_USER or LOG_MESSAGES.TRACK_EVENT.

tylerbrandt pushed a commit that referenced this issue 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 issue 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 issue 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 issue 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 issue 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 issue 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant