You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Worker class previously held a direct reference to a postgres.Sql connection 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 WorkerOptions interface that replaces the positional requestShutdown and sql constructor arguments. The worker now accepts an optional cleanup callback instead of a SQL instance directly, and only invokes it if one is provided. Both createFlowWorker and createQueueWorker track whether they created the SQL connection themselves (ownsSql), and only pass a cleanup callback 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.
requestShutdown on PlatformAdapter is now optional, and both worker factories use optional chaining when binding it. SupabasePlatformAdapter.stopWorker wraps the worker stop call in a try/finally block so the platform-owned SQL connection is always closed even if the worker stop throws.
The batch size limit parameter in ReadWithPollPoller and StepTaskPoller is now capped at the configured batchSize using Math.min, preventing a caller from requesting more messages than the poller is configured to handle.
New tests cover the cleanup callback invocation on worker stop, the ownsSql-conditional SQL teardown behavior, the sql.end guarantee when worker stop rejects, the optional requestShutdown type contract, and the corrected batch size capping logic in both poller implementations.
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.