Repository navigation
perf(web): load Infra auto top-up only when a transcript charge needs it - #4197
Merged
Merged
Conversation
|
Sandchest reviewed Sandchest reviews every change for vulnerabilities an attacker could use · 4 credits · Review details |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Member
Author
|
hey @greptileai, please re-review the PR |
This branch was successfully deployed
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.

Every workflow step ships in one bundle, so a module imported by one step is loaded by all of them on a cold start. Since #4156,
lib/developer-transcript-billing.ts(reached fromworkflows/developer-transcribe.ts) has importedscheduleAutoTopUpstatically. That pullslib/infra-auto-top-up.tsinto the bundle, and with it Stripe, Resend and the React Email templates. Regular transcription, processing and AI generation steps now load all three on every cold start, even though only Infra transcript charges use them.This PR loads the auto top-up module on first use in that one file, the way
lib/infra-storage-minimum.tsalready does. Behaviour is unchanged: the function and its arguments are the same, and it is still awaited at the same three call sites.Measurement
I built all 16
"use step"workflow files with esbuild (minified, ESM, code splitting) and summed only the code reachable through static imports from the entry files:stripe@react-email/*resendlib/infra-auto-top-up.tsWith this change, the only imports of
lib/infra-auto-top-up.tsfrom step code are dynamic ones. Loading Stripe, Resend and React Email unbundled took about 150 ms per cold process on a laptop, so that much comes off every workflow cold start.Testing
biome checkis clean on the changed file.

Confidence Score: 5/5
The PR appears safe to merge; no actionable regression was found.Summary
Defers loading
infra-auto-top-up.tsuntil transcript billing callsscheduleAutoTopUp, keeping its heavy dependencies out of the static import path.Reviews (2) · Last reviewed commit: "style(web): sort the auto top-up type im..." · Reviewed by Greptile