Closed zhawtof closed 8 months ago
Hi @zhawtof, thanks for the input. I personally don't call this a race codition, but I do understand your need here. As for your suggestions:
I pefer the 2. approach but instead of two types of lazy listeners, I'd like to add a new initizaliation option to customize the behavior called startLazyListenerAfterAck: boolean | undefined (undefined is the default value and it means false). This approach does not bring any breaking changes to existing apps. You can pass startLazyListenerAfterAck: true to the App constructor. Will submit a PR for it.
Thank you so much again for your input! v0.9.0 is now available with the new option.
Hey @seratch, we've recently run into a section of your code that we believe might have a better solution.
https://github.com/seratch/slack-edge/blob/21f917867b4e3313c7289601b053b210e02abeaf/src/app.ts#L667-L668
In the above code, the
lazy
function is triggered before theack
function. While this might be intended, we believe that thelazy
function would be substantially more useful if it was triggered after theack
function.Our thoughts in no particular order:
lazy
andack
both access and update the same information, this will cause a race condition.lazy
by its name implies that it would follow Lazy evaluation and only be triggered when resources are available. By triggering before ack, it still hogs resources that should be used forack
even if the processing is parallel.Real example
At the very onset of our product onboarding, we create an object that represents our platform. After our platform is created, we wanted to perform follow-on tasks that would continue preparing the rest of the platform behind the scenes. However, because
lazy
evaluates beforeack
evaluates, we cannot run any follow-on tasks since there is a race condition that the platform has yet to be created.Our current solution
Our solution (which I will add is perfectly reasonable) is to pass down the Cloudflare
ExecutionContext
and runwaitUntil
within theack
directly. We mention the suggestions because we believe it would improve theslack-edge
platform by abstracting Cloudflare capabilities.Our suggestion
1) Swap the order of ack and lazy
2) Introduce 3 commands. preAck, ack, postAck.
Would love to hear your thoughts! We love the platform and we're excited to scale with it!