fix(billing): preserve fetch_subscription flag through Redis queue serialization#3225
Open
firecrawl-spring[bot] wants to merge 2 commits intomainfrom
Open
fix(billing): preserve fetch_subscription flag through Redis queue serialization#3225firecrawl-spring[bot] wants to merge 2 commits intomainfrom
firecrawl-spring[bot] wants to merge 2 commits intomainfrom
Conversation
…rialization Browser sessions destroyed via webhook pass subscription_id as undefined, signaling that bill_team_6 should look up the subscription. However, queueBillingOperation coerces undefined to null before serializing to Redis. When supaBillTeam deserializes the operation, it checks subscription_id === undefined (which is now false, since it's null), so fetch_subscription is set to false. The RPC receives sub_id=null with fetch_subscription=false — it has no subscription to bill and isn't told to look one up. Credits are logged in credit_usage with a null subscription_id but never deducted from the subscription balance. Fix: capture the fetch_subscription intent as an explicit boolean before the undefined→null coercion, propagate it through the grouped operation, and pass it into supaBillTeam. Also add a defensive fallback in supaBillTeam: if subscription_id is null and fetch_subscription wasn't explicitly set, default to fetching. Co-Authored-By: devhims <himanshu@sideguide.dev>
…l subscription_ids
nickscamara
approved these changes
Mar 27, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
subscription_id: undefined(meaning "look it up"), butqueueBillingOperationcoerces it tonullbefore serializing to Redis. WhensupaBillTeamdeserializes,null === undefinedisfalse, sofetch_subscriptionis set tofalse. The RPC getssub_id=nullwithfetch_subscription=false— credits are logged incredit_usagebut never deducted from the subscription balancefetch_subscriptionboolean toBillingOperationandGroupedBillingOperation, captured before theundefined→nullcoercion, propagated through grouping, and passed intosupaBillTeamTest plan
Summary by cubic
Fixes a billing gap where webhook-destroyed browser sessions were logged but not charged by preserving the intent to fetch a subscription through Redis queuing and batching. Ensures
bill_team_6receives the correctfetch_subscriptionsignal so credits are deducted.fetch_subscriptionboolean toBillingOperationandGroupedBillingOperation, captured before theundefined→nullcoercion, propagated during grouping (group flag becomes true if any op needs lookup), and passed intosupaBillTeam.supaBillTeamto respect the preservedfetch_subscriptionflag even whensubscription_idisnull, and pass it through to the RPC without an implicit fallback that could override the flag.Written for commit b4db2ac. Summary will update on new commits.