fix(eval): stabilize eval error fingerprints and accurate .js type diagnostic#3090
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(eval): stabilize eval error fingerprints and accurate .js type diagnostic#3090posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
….js branch Errors thrown from the dynamically generated Function() body in evalCompiledJs carried anonymous/eval stack frames whose line/column offsets shift with the size of the compiled code, so error tracking fingerprinted otherwise-identical errors as separate issues. Strip those generated frames so repeat occurrences collapse into a single issue. Also run getTypeExportsFromCode (and set __typeOnlyExports__) in the .js/.mjs branch of import-local-file, mirroring the .ts/.tsx branch, so type-only exports surfaced through .js modules get the accurate "this is a type" diagnostic. Generated-By: PostHog Code Task-Id: 88cbfcc3-c4a7-454c-9a97-c3f645b65a90
|
This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. |
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
The eval engine surfaced confusing
"…" is not exported by "…"errors for.jsimports and filed a fresh error-tracking issue for each occurrence of the identical error. Two tightly related changes in the same area:Function()body inevalCompiledJscarried anonymous/eval stack frames whose line/column offsets shift with the size of the compiled code, so error tracking fingerprinted otherwise-identical errors as separate issues.evalCompiledJsnow strips those generated frames, leaving a stable stack anchored at real source locations so repeat occurrences collapse into one issue..jstype diagnostic. The.js/.mjsbranch ofimport-local-filenow runsgetTypeExportsFromCodeand sets__typeOnlyExports__, mirroring the.ts/.tsxbranch, so type-only exports surfaced through.jsmodules get the accurate "this is a type, useexport type" diagnostic instead of the generic message.Why
One logical eval failure was fragmenting the error-tracking inbox into multiple issues (the identical
defaultProps/./external.jsmessage spawned three distinct issues within seconds), and.jsimports skipped the friendlier type-only diagnostic that the.tsbranch already provided. Measured impact is small — this is primarily inbox-noise cleanup.Notes for reviewers
.jsmodule re-exports a type from a.tsmodule (a literalexport typeinside a.jsfile is rejected by the transpiler before it ever runs). ThegetTypeExportsFromCodeaddition brings the.jsbranch to full parity with the.tsbranch for that case, and is harmless otherwise — the proxy only consults__typeOnlyExports__for names that are genuinely absent at runtime.<anonymous>:,eval at …, bun's bareat anonymous () and leaves legitimate anonymous library frames intact.Tests
tests/features/eval-error-stable-stack.test.ts— asserts eval errors carry no generated frames and that identical errors produce identical fingerprint-relevant frames regardless of compiled-code size.tests/features/type-import-check-js.test.tsx— asserts the accurate "is a type" diagnostic for a type imported through a.jsmodule.Created with PostHog Code from an inbox report.