Skip to content

test(eventual-send): Demonstrate disappearing deep stacks #1591

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions packages/eventual-send/test/test-await-no-deep-stacks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// This file is not very useful as an
// automated test. Rather, its purpose is just to run it to see what a
// deep stack looks like.

import { test } from './prepare-test-env-ava.js';

test('no-deep-stacks then', t => {
let r;
const p = new Promise(res => (r = res));
const q = (async () => assert.equal(await ((await p) + 1), 22))();
r(33);
return (async () => {
try {
await q;
} catch (reason) {
t.assert(reason instanceof Error);
console.log('expected failure', reason);
}
})();
});

/*
prepare-test-env-ava sets the `"stackFiltering"` option to `lockdown` to
`"verbose"`. For expository purposes, if the `"stackFiltering"` option to
`lockdown` is set to `"concise"` you should see something like the
following. What you should actually see with `"verbose"` is like this, but with
much extraneous information --- infrastructure stack frames and longer file
paths. See
https://github.com/endojs/endo/blob/master/packages/ses/lockdown-options.md

```
$ ava test/test-await-no-deep-stacks.js

expected failure (RangeError#1)
RangeError#1: Expected 34 is same as 22
at packages/eventual-send/test/test-await-no-deep-stacks.js:11:33
at async packages/eventual-send/test/test-await-no-deep-stacks.js:15:7
```

If you're in a shell or IDE that supports it, try clicking (or command-clicking
or something) on the file paths for test-await-no-deep-stacks.js You should see
one invocation and one await together in one stack as if they occurred in the
same turn. No other turns are visible. Compare with
test-deep-send.js or test-deep-stacks.js to see the debugging advantage of using
eventual-send (`E`) or `E.when` instead.
*/
37 changes: 36 additions & 1 deletion packages/eventual-send/test/test-deep-send.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file does not start with "test-" because it is useful as an
// This file is not very useful as an
// automated test. Rather, its purpose is just to run it to see what a
// deep stack looks like.

Expand Down Expand Up @@ -28,3 +28,38 @@ test('deep-stacks E', t => {
console.log('expected failure', reason);
});
});

/*
prepare-test-env-ava sets the `"stackFiltering"` option to `lockdown` to
`"verbose"`. For expository purposes, if the `"stackFiltering"` option to
`lockdown` is set to `"concise"` you should see something like the
following. What you should actually see with `"verbose"` is like this, but with
much extraneous information --- infrastructure stack frames and longer file
paths. See
https://github.com/endojs/endo/blob/master/packages/ses/lockdown-options.md

```
$ ava test/test-deep-send.js

expected failure (Error#1)
Error#1: Wut?
at Object.bar (packages/eventual-send/test/test-deep-send.js:13:21)

Error#1 ERROR_NOTE: Thrown from: (Error#2) : 2 . 0
Error#1 ERROR_NOTE: Rejection from: (Error#3) : 1 . 1
Nested 2 errors under Error#1
Error#2: Event: 1.1
at Object.foo (packages/eventual-send/test/test-deep-send.js:17:28)

Error#2 ERROR_NOTE: Caused by: (Error#3)
Nested error under Error#2
Error#3: Event: 0.1
at Object.test (packages/eventual-send/test/test-deep-send.js:21:22)
at packages/eventual-send/test/test-deep-send.js:25:19
at async Promise.all (index 0)
```

If you're in a shell or IDE that supports it, try clicking (or command-clicking
or something) on the file paths for test-deep-send.js You should see that there
are four invocations that were spread over three turns.
*/
36 changes: 35 additions & 1 deletion packages/eventual-send/test/test-deep-stacks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file does not start with "test-" because it is useful as an
// This file is not very useful as an
// automated test. Rather, its purpose is just to run it to see what a
// deep stack looks like.

Expand All @@ -16,3 +16,37 @@ test('deep-stacks when', t => {
console.log('expected failure', reason);
});
});

/*
prepare-test-env-ava sets the `"stackFiltering"` option to `lockdown` to
`"verbose"`. For expository purposes, if the `"stackFiltering"` option to
`lockdown` is set to `"concise"` you should see something like the
following. What you should actually see with `"verbose"` is like this, but with
much extraneous information --- infrastructure stack frames and longer file
paths. See
https://github.com/endojs/endo/blob/master/packages/ses/lockdown-options.md

```
$ ava test/test-deep-stacks.js

expected failure (RangeError#1)
RangeError#1: Expected 34 is same as 22
at packages/eventual-send/test/test-deep-stacks.js:13:57

RangeError#1 ERROR_NOTE: Thrown from: (Error#2) : 2 . 0
RangeError#1 ERROR_NOTE: Rejection from: (Error#3) : 1 . 1
Nested 2 errors under RangeError#1
Error#2: Event: 1.1
at packages/eventual-send/test/test-deep-stacks.js:13:31

Error#2 ERROR_NOTE: Caused by: (Error#3)
Nested error under Error#2
Error#3: Event: 0.1
at packages/eventual-send/test/test-deep-stacks.js:13:15
at async Promise.all (index 0)
```

If you're in a shell or IDE that supports it, try clicking (or command-clicking
or something) on the file paths for test-deep-stacks.js You should see that there
are three invocations that were spread over three turns.
*/
42 changes: 42 additions & 0 deletions packages/eventual-send/test/test-then-no-deep-stacks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// This file is not very useful as an
// automated test. Rather, its purpose is just to run it to see what a
// deep stack looks like.

import { test } from './prepare-test-env-ava.js';

test('no-deep-stacks then', t => {
let r;
const p = new Promise(res => (r = res));
const q = p.then(v1 =>
Promise.resolve(v1 + 1).then(v2 => assert.equal(v2, 22)),
);
r(33);
return q.catch(reason => {
t.assert(reason instanceof Error);
console.log('expected failure', reason);
});
});

/*
prepare-test-env-ava sets the `"stackFiltering"` option to `lockdown` to
`"verbose"`. For expository purposes, if the `"stackFiltering"` option to
`lockdown` is set to `"concise"` you should see something like the
following. What you should actually see with `"verbose"` is like this, but with
much extraneous information --- infrastructure stack frames and longer file
paths. See
https://github.com/endojs/endo/blob/master/packages/ses/lockdown-options.md

```
$ ava test/test-then-no-deep-stacks.js

expected failure (RangeError#1)
RangeError#1: Expected 34 is same as 22
at packages/eventual-send/test/test-then-no-deep-stacks.js:12:47
```

If you're in a shell or IDE that supports it, try clicking (or command-clicking
or something) on the file path for test-then-no-deep-stacks.js You should see
only the last invocation with its stack from that one last turn. Compare with
test-deep-send.js or test-deep-stacks.js to see the debugging advantage of using
eventual-send (`E`) or `E.when` instead.
*/