fix: cap poller batch size at config limit and make cleanup/requestShutdown optional#622
fix: cap poller batch size at config limit and make cleanup/requestShutdown optional#622jumski wants to merge 1 commit into
Conversation
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
View your CI Pipeline Execution ↗ for commit dc209fb
☁️ Nx Cloud last updated this comment at |

The
Workerclass previously held a direct reference to apostgres.Sqlconnection and always closed it on shutdown. This coupling meant the worker unconditionally owned the SQL connection regardless of whether it was externally provided.This change introduces a
WorkerOptionsinterface that replaces the positionalrequestShutdownandsqlconstructor arguments. The worker now accepts an optionalcleanupcallback instead of a SQL instance directly, and only invokes it if one is provided. BothcreateFlowWorkerandcreateQueueWorkertrack whether they created the SQL connection themselves (ownsSql), and only pass acleanupcallback that closes the connection when they own it. When a SQL connection is passed in via config, the worker leaves lifecycle management of that connection to the caller.requestShutdownonPlatformAdapteris now optional, and both worker factories use optional chaining when binding it.SupabasePlatformAdapter.stopWorkerwraps the worker stop call in atry/finallyblock so the platform-owned SQL connection is always closed even if the worker stop throws.The batch size
limitparameter inReadWithPollPollerandStepTaskPolleris now capped at the configuredbatchSizeusingMath.min, preventing a caller from requesting more messages than the poller is configured to handle.New tests cover the
cleanupcallback invocation on worker stop, theownsSql-conditional SQL teardown behavior, thesql.endguarantee when worker stop rejects, the optionalrequestShutdowntype contract, and the corrected batch size capping logic in both poller implementations.