Repository navigation
Format the cached origin stack right away so it doesn't keep caller closures alive - #1275
Open
illia-haidar wants to merge 2 commits into
Open
illia-haidar wants to merge 2 commits into
illia-haidar wants to merge 2 commits into
Conversation
This was referenced Oct 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.
Fixes #1274
cachedError()caches oneErrorper tagged-template call site. Until its.stackis read, V8 keeps the structured call sites, and through them the first caller's closure, alive for as long asoriginCachelives, which is the life of the process. This formats the stack right after creating the error, once per call site, so the cached error only holds a string.Error.stackTraceLimit: restored before the stack is formatted, so a user-definedError.prepareStackTracenever runs while the limit is temporarily 4.Error.prepareStackTrace: leaves the error unformatted, as before.Errorper query (Expensive instantiation of Errors to capture stack traces? #290).The new test,
Origin stack is formatted when a query is created, countsError.prepareStackTracecalls while a new call site creates its query, before the query runs.1 != 0).Error.prepareStackTrace.Locally, against PostgreSQL 17:
tests/index.js(ESM) passes on Node 26.0.0 and 24.22.1, all 265 tests;npm run build:cjs,cjs/tests) passes too;eslint src testsis clean.cjs/,deno/andcf/are left for the build step.