Skip to content

Conversation

@kinyoklion
Copy link
Contributor

@kinyoklion kinyoklion commented Aug 6, 2025

Add an option that allows for reconnects to be disabled when doing an async get request. Currently I only added this option to the async path as I am unsure of how the reconnect feature is intended to be used.

I've tried this approach with the LaunchDarkly SDK and it resolved the issue we were encountering with the reconnect feature #202.

Original issue: launchdarkly/erlang-server-sdk#155

@kinyoklion
Copy link
Contributor Author

Not sure about this handling in at_rest.

% this state transition is not expected because gun messages change state to 'down'.
% but just in case ...
at_rest(cast, {gun_down, _Args, _From}, StateData = #{pid := Pid}) ->

Copy link
Member

@elbrujohalcon elbrujohalcon left a comment

Choose a reason for hiding this comment

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

It looks good to me, just a little nit-picking.
Any chance we can add some tests for this?

@kinyoklion
Copy link
Contributor Author

Any chance we can add some tests for this?

I will take a stab at it.

@kinyoklion
Copy link
Contributor Author

@elbrujohalcon Addressed feedback and added tests.

@elbrujohalcon elbrujohalcon merged commit 034cc00 into inaka:master Aug 8, 2025
@elbrujohalcon
Copy link
Member

Thanks, @kinyoklion ! You've got a new release now: https://hex.pm/packages/shotgun/1.2.1

kinyoklion added a commit to launchdarkly/erlang-server-sdk that referenced this pull request Aug 8, 2025
BEGIN_COMMIT_OVERRIDE
feat: Update minimum OTP version to 24.
fix: Fix issue where sometimes a dropped stream would not reconnect.
END_COMMIT_OVERRIDE

In shotgun 1.1.0 a new feature was introduced which introduced a bug
with the SSE connection. Where previously it would close its process in
all cases where it disconnected, now it would not do that in some
situations. This caused #155.

We contributed an update to shotgun to allow disabling the feature for
async connections where you need to monitor the connection state.
inaka/shotgun#203

This was released in shotgun 1.2.1.

This PR updates to 1.2.1 and uses the option to disable the `reopen`
feature added in shotgun 1.1.0.
This PR also raises the minimum erlang version to 24. This is required
to gun 2.2 which shotgun 1.2.0 and newer depends on. OTP doesn't have an
official support timeline, but OTP 24 came out in 2021, so most people
will likely be on 24 or greater especially when using elixir.
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

Successfully merging this pull request may close these issues.

2 participants