File tree Expand file tree Collapse file tree 4 files changed +43
-3
lines changed
Expand file tree Collapse file tree 4 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -722,3 +722,9 @@ wd_test(
722722 args = ["--experimental" ],
723723 data = ["buffer-effective-size-concat-test.js" ],
724724)
725+
726+ wd_test (
727+ src = "als-gc-test.wd-test" ,
728+ args = ["--experimental" ],
729+ data = ["als-gc-test.js" ],
730+ )
Original file line number Diff line number Diff line change 1+ import { AsyncLocalStorage } from 'node:async_hooks' ;
2+
3+ const store = new AsyncLocalStorage ( ) ;
4+
5+ export const test = {
6+ test ( ) {
7+ const outerValue = crypto . randomUUID ( ) ;
8+ ( { [ outerValue ] : `value doesn't matter here` } ) ;
9+ store . run ( outerValue , ( ) => {
10+ for ( let i = 0 ; i < 1_000 ; i ++ ) {
11+ const storeValue = store . getStore ( ) ;
12+ if ( ! storeValue ) {
13+ throw new Error ( `Failed on attempt ${ i } .` ) ;
14+ }
15+ for ( let j = 0 ; j < 1_000 ; j ++ ) {
16+ ( ( ) => Math . random ( ) ) ( ) ;
17+ }
18+ }
19+ } ) ;
20+ } ,
21+ } ;
Original file line number Diff line number Diff line change 1+ using Workerd = import "/workerd/workerd.capnp";
2+
3+ const unitTests :Workerd.Config = (
4+ services = [
5+ ( name = "als-gc-test",
6+ worker = (
7+ modules = [
8+ (name = "worker", esModule = embed "als-gc-test.js")
9+ ],
10+ compatibilityFlags = ["nodejs_compat", "nodejs_compat_v2"]
11+ )
12+ ),
13+ ],
14+ );
Original file line number Diff line number Diff line change @@ -187,8 +187,7 @@ v8::Local<v8::Object> AsyncContextFrame::getJSWrapper(Lock& js) {
187187}
188188
189189void AsyncContextFrame::jsgVisitForGc (GcVisitor& visitor) {
190- for (auto & entry: storage) {
191- visitor.visit (entry.value );
192- }
190+ // tracing will make the members weak and will allow
191+ // them to be gc'd, which is not what we want.
193192}
194193} // namespace workerd::jsg
You can’t perform that action at this time.
0 commit comments