fix(base): keep prefetchCount default when config.channel is empty - #54
fix(base): keep prefetchCount default when config.channel is empty#54arsalan507 wants to merge 1 commit into
Conversation
The constructor merged the default channel object with the caller's
config via `{ channel: { prefetchCount: 1 }, ...config }`. Any
caller-supplied `channel` key, even an empty `{}`, replaced the
default object wholesale via the top-level spread, silently dropping
prefetchCount and leaving `channel.prefetch(undefined)` on connect.
Merge `channel` key-by-key instead, so the default only fills in keys
the caller didn't set.
Fixes bitrix24#30
|
Friendly ping — the CI runs on #54, #55 and #56 are all sitting at |
|
Hi Igor — thanks again for the #385 review, and for the GB9 catch. I'd have carried that mislabelled fixture forward otherwise. While you're in this corner of things: #54, #55 and #56 here are still waiting on the first-time-contributor workflow approval, so CI has never actually run on any of them. There's nothing to review yet — it's one click on "Approve and run workflows" and they'll either go green or tell us something useful. They're small and independent: #54 restores the No rush if this repo isn't a priority right now — just flagging that they're stuck on the gate rather than on anything I can do from my side. |
Summary
Fixes #30.
RabbitMQBase's constructor built the merged config as:Because
...configis a top-level spread, any caller-suppliedchannelkey — even a present-but-emptychannel: {}— replaces the default object wholesale instead of merging into it.prefetchCountis silently dropped, andchannel.prefetch(this.config.channel!.prefetchCount!)inConsumer.connect()ends up callingchannel.prefetch(undefined).Fix
Merge
channelkey-by-key instead of spreading the whole config over the default:Now the default only fills in keys the caller didn't set, matching the merge convention already used for queue
argumentsinregisterQueue().Test plan
tests/consumer.test.ts) that constructs a consumer withchannel: {}and assertschannel.prefetchis called with the default1. Verified it fails against the pre-fix code (channel.prefetchcalled withundefined) and passes after the fix.prefetchCountstill overrides the default.pnpm lint,pnpm typecheck,pnpm test(77 passing),pnpm buildall green.