GeezerVison is showing github.com — async_hooks: add an InactiveAsyncContextFrame class · nodejs/node@027b0ff
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/async_context_frame.js +9-7Lines changed: 9 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,7 +11,7 @@ const { |
11 | 11 |
|
12 | 12 | let enabled_; |
13 | 13 |
|
14 | | -class ActiveAsyncContextFrame { |
| 14 | +class ActiveAsyncContextFrame extends Map { |
15 | 15 | static get enabled() { |
16 | 16 | return true; |
17 | 17 | } |
@@ -50,12 +50,7 @@ function checkEnabled() { |
50 | 50 | return enabled; |
51 | 51 | } |
52 | 52 |
|
53 | | -class AsyncContextFrame extends Map { |
54 | | - constructor(store, data) { |
55 | | - super(AsyncContextFrame.current()); |
56 | | - this.set(store, data); |
57 | | - } |
58 | | - |
| 53 | +class InactiveAsyncContextFrame extends Map { |
59 | 54 | static get enabled() { |
60 | 55 | enabled_ ??= checkEnabled(); |
61 | 56 | return enabled_; |
@@ -65,6 +60,13 @@ class AsyncContextFrame extends Map { |
65 | 60 | static set(frame) {} |
66 | 61 | static exchange(frame) {} |
67 | 62 | static disable(store) {} |
| 63 | +} |
| 64 | + |
| 65 | +class AsyncContextFrame extends InactiveAsyncContextFrame { |
| 66 | + constructor(store, data) { |
| 67 | + super(AsyncContextFrame.current()); |
| 68 | + this.set(store, data); |
| 69 | + } |
68 | 70 |
|
69 | 71 | disable(store) { |
70 | 72 | this.delete(store); |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-async-context-frame.mjs +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,6 +5,7 @@ import { opendir } from 'node:fs/promises'; |
5 | 5 | import { fileURLToPath } from 'node:url'; |
6 | 6 | import { describe, it } from 'node:test'; |
7 | 7 | import { sep } from 'node:path'; |
| 8 | +import { strictEqual } from 'node:assert'; |
8 | 9 |
|
9 | 10 | const python = process.env.PYTHON || (isWindows ? 'python' : 'python3'); |
10 | 11 |
|
@@ -53,7 +54,8 @@ describe('AsyncContextFrame', { |
53 | 54 | stdio: ['ignore', 'ignore', 'inherit'], |
54 | 55 | }); |
55 | 56 |
|
56 | | - await once(proc, 'exit'); |
| 57 | + const [code] = await once(proc, 'exit'); |
| 58 | + strictEqual(code, 0, `Test ${test} failed with exit code ${code}`); |
57 | 59 | }); |
58 | 60 | } |
59 | 61 | }); |