Skip to content

Rewrite CookieAdapter to work with Rack::Request and Rack::Response directly - #490

Merged
andrew merged 1 commit into
splitrb:masterfrom
andrehjr:fix-force-cookie
Jun 5, 2017
Merged

Rewrite CookieAdapter to work with Rack::Request and Rack::Response directly#490
andrew merged 1 commit into
splitrb:masterfrom
andrehjr:fix-force-cookie

Conversation

@andrehjr

@andrehjr andrehjr commented Jun 4, 2017

Copy link
Copy Markdown
Member

CookieAdapter receives the 'context' passed down to the User instance. Which is different on a Sinatra(Dashboard) and a Rails App.

As they are both Rack instances, the easier way to keep it working for both Rails and Sinatra I used the request/response to read/write the cookies from Rack directly.

Also updated the Specs to test against mock Rack requests. @andrew Please let me know what you think!

Fixes #480

@andrew

andrew commented Jun 5, 2017

Copy link
Copy Markdown
Member

Looks good to me, thanks so much for your contribution 🎉

@andrew
andrew merged commit e6ff873 into splitrb:master Jun 5, 2017
@andrehjr
andrehjr deleted the fix-force-cookie branch June 5, 2017 13:18
@itspriddle

Copy link
Copy Markdown

Hi @andrew, any chance we can get a new gem release that includes this PR? Thanks!

@andrew andrew self-assigned this Aug 12, 2017
@andrew

andrew commented Aug 12, 2017

Copy link
Copy Markdown
Member

@itspriddle sorry for the delay, I'll get a release out within the next couple days

@andrew

andrew commented Aug 14, 2017

Copy link
Copy Markdown
Member
:expires => @expires
}
def set_cookie(value = {})
@response.set_cookie :split.to_s, default_options.merge(value: JSON.generate(value))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this change may be causing split to send back multiple Set-Cookie headers in the case where a participant is involved in more than one split test. Version 3.0.0 did not have this problem. But after upgrading to 3.1.0 (which included this PR), I started seeing one Set-Cookie response headers for every experiment mentioned in the cookie submitted by the client.

In a few cases, the cookies had enough experiments in them that my load balancer rejected the response as invalid.

Downgrading to 3.0.0 fixed the problem.

I think that @response.set_cookie is writing a new cookie each time it is called. However, @cookies[:split] was overwriting the previous value of the cookie in place.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This demonstrates the issue: #508

@andrew andrew removed their assignment Aug 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants