Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

[Bug] Redis reconnect on connection issue#442

Merged
paulomarg merged 8 commits into
Shopify:mainfrom
ocastx:fix/redis-reconnect-issue
Aug 19, 2022
Merged

[Bug] Redis reconnect on connection issue#442
paulomarg merged 8 commits into
Shopify:mainfrom
ocastx:fix/redis-reconnect-issue

Conversation

@ocastx
Copy link
Copy Markdown
Contributor

@ocastx ocastx commented Aug 1, 2022

WHY are these changes introduced?

Fixes #440

If redis client library looses connection an error is thrown which is currently unhandled. This makes it especially problematic in ephemeral cloud environments like Heroku which leaves the app in a crashed state after idle time.

WHAT is this pull request doing?

Type of change

  • Patch: Bug (non-breaking change which fixes an issue)
  • Minor: New feature (non-breaking change which adds functionality)
  • Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have added a changelog entry, prefixed by the type of change noted above
  • I have added/updated tests for this change
  • I have documented new APIs/updated the documentation for modified APIs (for public APIs)

@ocastx ocastx requested a review from a team as a code owner August 1, 2022 12:49
@ocastx ocastx closed this Aug 1, 2022
@ocastx ocastx reopened this Aug 1, 2022
@ocastx ocastx force-pushed the fix/redis-reconnect-issue branch from 32e7c59 to 810d62f Compare August 1, 2022 12:55
@walkingbrad
Copy link
Copy Markdown

Or perhaps provide a way to pass in or set an error handler so redis errors can be logged

Comment thread src/auth/session/storage/redis.ts Outdated
Comment on lines +109 to +118
socket: this.options.socket,
username: this.options.username,
password: this.options.password,
name: this.options.name,
database: this.options.database,
commandsQueueMaxLength: this.options.commandsQueueMaxLength,
disableOfflineQueue: this.options.disableOfflineQueue,
readonly: this.options.disableOfflineQueue,
legacyMode: this.options.legacyMode,
isolationPoolOptions: this.options.isolationPoolOptions,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like the general idea (thanks!), but I'm not sure we want to explicitly add the options here, rather than spread this.options. Was there a particular reason for doing that here that I'm missing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Definitely, using spread operator makes it much easier to read.

I was having troubles with making types work, because of a known Redis issue regarding RedisClientType. I added a solution towards it which was previously discussed in their repo.

@ocastx ocastx requested a review from paulomarg August 9, 2022 09:06
Comment thread src/auth/session/storage/redis.ts Outdated
Comment on lines +113 to +116
this.client.on(
'error',
this.options.onError ? this.options.onError : () => {},
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can merge this, but there's just one little thing I missed before - it would probably make more sense to skip setting this handler at all if onError isn't defined, rather than making it an empty function.

If you could make that change, we can go ahead and merge this 🙂

Copy link
Copy Markdown
Contributor

@paulomarg paulomarg left a comment

Choose a reason for hiding this comment

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

🎉

I think you might need to rebase so that we can merge!

@paulomarg paulomarg merged commit fbcae66 into Shopify:main Aug 19, 2022
@ocastx ocastx deleted the fix/redis-reconnect-issue branch August 19, 2022 16:09
@shopify-shipit shopify-shipit Bot temporarily deployed to production September 19, 2022 19:28 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RedisSessionStorage reconnect issue

3 participants