Skip to content

Conversation

archessmn
Copy link
Member

This should hopefully reduce the logged messages from the slack connection restarting.

Copy link
Member

@markspolakovs markspolakovs left a comment

Choose a reason for hiding this comment

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

Makes sense, but I'm not sure reverting the global cache is correct.

if (!app && isSlackEnabled) {
app = global.slack = new App({
async function slackApiConnection() {
return new App({
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure there aren't places where this would get called twice per request?

(Also, why is this change necessary? Surely the persistent server has its own memory space so can have its own global slack client cache. If the only reason is to avoid calling app.start(), you could pass in a shouldStartApp = false parameter.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't think that the global cache actually did much but am happy to revert it if that is the case. Having app.start() separate is preferable, as the boltjs example code shows listeners etc being declared before starting the app, which wouldn't be possible if the app was started before being returned.

Copy link
Member

Choose a reason for hiding this comment

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

The main benefit of the global cache is not creating multiple Apps if slackApiConnection() is called more than once per request - I'm not sure if we do it (we shouldn't), but it's a decent precaution. It also saves on some overhead between requests (I'm not sure how expensive an App is to create).

@jenkins-ystv
Copy link

jenkins-ystv bot commented Sep 12, 2024

Deployed a preview of this PR to https://pr-154-internal.dev.ystv.co.uk

@markspolakovs markspolakovs merged commit 078eab8 into main Sep 12, 2024
3 checks passed
@markspolakovs markspolakovs deleted the int-194-error-unhandled-event-server-disconnect-old-socket-in-state branch September 12, 2024 22:50
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