Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests in TypeScript (.ts files) lack stack traces #2348

Closed
erights opened this issue Jul 12, 2024 · 1 comment · Fixed by #2355
Closed

tests in TypeScript (.ts files) lack stack traces #2348

erights opened this issue Jul 12, 2024 · 1 comment · Fixed by #2355
Assignees
Labels
bug Something isn't working

Comments

@erights
Copy link
Contributor

erights commented Jul 12, 2024

See Agoric/agoric-sdk#8662

From Agoric/agoric-sdk#9700

file://test/facade.test.ts:1:1043

vs

(test/facade.test.ts:52:9)

Why are we seeing this difference? Clearly, the second stack trace is more informative, and the tamed stack trace from Endo, whether 'safe' or 'unsafe', should show this more informative one. It looks like the second is relative to the source code the programmer wrote, which is ideal. But of course, the source is TS and what's executing is the JS that the TS compiles to. From the first, I'd guess that either the TS compiler is compiling into a single line of JS, or that some bundler is flattening the compiled JS into a single line of JS. But in either case, we should understand why the second stack trace is more informative. Is it based on a source map generated by the TS compiler? How does the native v8 stack get to be adjusted for that, but not the stack we're forming using the JS error API internally?

@mhofman
Copy link
Contributor

mhofman commented Jul 12, 2024

I'd guess that either the TS compiler is compiling into a single line of JS

Correct

we should understand why the second stack trace is more informative. Is it based on a source map generated by the TS compiler? How does the native v8 stack get to be adjusted for that, but not the stack we're forming using the JS error API internally?

TS does generate source maps. And Node.js uses prepareStackTrace to parse source maps and recreate the authored stack trace info. v8 itself doesn't know anything about source maps. However when SES overrides prepareStackTrace, we lose that Node.js behavior aware of source maps. Since we can't invoke that original behavior because of strange layering inside Node.js, we're left with having to re-implement the source mapping behavior ourselves in SES. See #1798

erights added a commit that referenced this issue Jul 14, 2024
erights added a commit that referenced this issue Jul 14, 2024
mergify bot pushed a commit to Agoric/agoric-sdk that referenced this issue Jul 19, 2024
closes: #8662 
refs: endojs/endo#2355 endojs/endo#2348

## Description

endojs/endo#2355 makes it possible to see accurate line numbers into TypeScript Ava tests run under Node, which would fix #8662 as of the next endo-release-agoric-sdk-sync cycle. To get this benefit before then, this PR turns endojs/endo#2355 into an agoric-sdk patch of endo. This PR also adds a test case to demonstrate that the fix works, and updates the `env.md` file to document the new environment variable for enabling this behavior.

### Security Considerations

See Security Consideration of endojs/endo#2355 . In short, this feature sacrifices security for a better test-debug experience, which is fine for ***development only***.

### Scaling Considerations
none

### Documentation Considerations
See Documentation Considerations of endojs/endo#2355

### Testing Considerations

This PR effectively serves as a test both for endojs/endo#2355 and for the corresponding patch in this PR.

### Upgrade Considerations
none.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants