Skip to content

firestore: only pay .stack cost in error paths - #9102

Open
rockwotj wants to merge 1 commit into
googleapis:mainfrom
rockwotj:callsite-error
Open

firestore: only pay .stack cost in error paths#9102
rockwotj wants to merge 1 commit into
googleapis:mainfrom
rockwotj:callsite-error

Conversation

@rockwotj

@rockwotj rockwotj commented Aug 6, 2026

Copy link
Copy Markdown

.stack is relatively expensive to compute and currently every RPC in
Firestore captures the stack, although it's only used in the error cases.

We can improve the performance in V8 by deferring source map resolution
to only error cases.

`.stack` is relatively expensive to compute and currently every RPC in
Firestore captures the stack, although it's only used in the error cases.

We can improve the performance in V8 by deferring source map resolution
to only error cases.
@rockwotj
rockwotj requested a review from a team as a code owner August 6, 2026 16:42
@product-auto-label product-auto-label Bot added the api: firestore Issues related to the Firestore API. label Aug 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors how callsite error stacks are captured across several Firestore files by storing the Error object itself (as callsiteError) and deferring the .stack access. However, a critical compilation error was introduced in bulk-writer.ts where a reference to the old stack variable was missed in a catch block.

Comment thread handwritten/firestore/dev/src/bulk-writer.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the Firestore API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant