-
Notifications
You must be signed in to change notification settings - Fork 212
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
fix(deps): stop taming stack trace with 'unsafe' #9700
Conversation
I am really concerned about such an intrusive patch. Is there no way to pass a lockdown config for the affected tests only? |
vs
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? |
I just assigned this to myself, as well as the bugs #8662 and endojs/endo#2348 , with the former closed as subsumed by the latter. I'm gonna close this because an endo bug should not first be solved with an agoric-sdk patch to endo. It should first be solved in an endo PR. Only then, we can turn that endo bug fix into an agoric-sdk patch if needed, in order to be able to use the bug fix before waiting for an endo release. Doing it that way also helps ensure that when we do the next endo-release-agoric-sdk-sync, we're up to date on the change and can delete the patch. |
Superseded by #9711 |
Closes: #2348 Refs: Agoric/agoric-sdk#9711 #1798 #1799 Agoric/agoric-sdk#8662 Agoric/agoric-sdk#9700 ## Description Prior to this PR, when you ran on Ava on Node a test written in TypeScript, you'd see something like the following in your stack traces. ``` boot/test/bootstrapTests/stack-linenumbers.test.ts:1:104 ``` This is because the TypeScript compiler compiles a TypeScripy file into one line of JavaScript with a sourceMap that should map back into original source positions. Node specifically makes use of that sourceMap to produce original line-numbers. However, Node does this in a way that resists virtualization, so the normal SES error taming cannot use this sourceMap info. By default, this PR does not change this behavior. However it recognizes a new `SUPPRESS_NODE_ERROR_TAMING` environment variable. With the `SUPPRESS_NODE_ERROR_TAMING` environment variable absent or set to `'disabled'`, you should still see stack traces as shown above However, if you also set the `SUPPRESS_NODE_ERROR_TAMING` environment variable `'enabled'`, for example by doing ```sh $ export SUPPRESS_NODE_ERROR_TAMING=enabled ``` at a bash shell, then when you run this test you should instead see something like ``` boot/test/bootstrapTests/stack-linenumbers.test.ts:40:32 ``` At Agoric/agoric-sdk#9711 I both - turn this PR into an agoric-sdk patch of endo, in order to emulate this fix until the next endo-release-agoric-sdk-sync cycle, and - add a test case that emits an error stack trace from an Ava test case written in TypeScript, to test that it works. ### Security Considerations This new behavior only applies when `errorTaming: 'unsafe'`, on v8, and with this new environment variable enabled. Setting `errorTaming: 'unsafe'` already flags to sacrifice some security for a better debugging experience. But the loss of security is moderate enough --- mostly confidentiality rather than integrity --- that some may chose this setting for some production purposes. The new behavior is a more severe loss of security that really should be used ***only during development***, not production, when even a severe loss of security is usually not an issue. ### Scaling Considerations none ### Documentation Considerations The behavior prior to this PR or without this environment variable enabled is an unpleasant debugging experience. However, developers won't know how to repair it, or even that it can be repaired, without explanation. Even then, the difficultly of discovery in a problem. The names `SUPPRESS_NODE_ERROR_TAMING` and the settings `'enabled'` and `'disabled'` are by no means clear expressions of what this does. Reviewers, ***better names would be appreciated!*** ### Testing Considerations The point. As developers write and run tests written in TypeScript, they need to iterate with problems revealed by the tests, for which they need good line numbers, including into the test code. When the environment variable is enabled, the new behavior broke some SES tests written specifically to test the old behavior. This would not happen under CI because the environment variable is not set by default, and so may not have been noticed. But it was revealed in local testing. To repair this, this PR also sets those tests up to set `process.env.SUPPRESS_NODE_ERROR_TAMING` to `'disabled'` before lockdown, protecting those tests from the external environment variable setting. Awkwardly, at the moment Agoric/agoric-sdk#9711 serves as the only test of this PR. This is because I failed to figure out how to configure things so I can run TypeScript tests under Ava, like Agoric/agoric-sdk#9711 does. I tried cargo culting the configs that seemed relevant, but it didn't work. Reviewers, if you let me know how to do this, I'll duplicate the test case from Agoric/agoric-sdk#9711 here, which would be good. ### Compatibility Considerations With the environment variable absent or disabled, there should be zero difference in behavior, so none. In a development environment where this environment variable is enabled, some stack traces will be different. But outside of SES itself, nothing should depend on the contents of stack traces, so again none. ### Upgrade Considerations No upgrade considerations. Nothing BREAKING. - [x] Update `NEWS.md` for user-facing changes.
closes: #8662
Description
If there's an error in a
.ts
test, the stack trace is without a useful line number:This patches
ses
so leave the stack trace alone in v8 iferrorTaming: 'unsafe'
.Security Considerations
More aggressively unsafe error taming, but only in V8 which does not run on chain.
Scaling Considerations
none
Documentation Considerations
This would differ from Endo. I don't know whether Endo should have this exact change or not. I'm just trying to get my tests in agoric-sdk working properly.
Testing Considerations
Tested locally by forcing an error and seeing the change above.
Upgrade Considerations
n/a